Ticket #5765: log-5765.patch

File log-5765.patch, 4.2 KB (added by thijs, 4 years ago)
  • twisted/trial/unittest.py

     
    537537    def _add(self):
    538538        if self._added == 0:
    539539            log.addObserver(self.gotEvent)
    540             self._oldFE, log._flushErrors = (log._flushErrors, self.flushErrors)
    541             self._oldIE, log._ignore = (log._ignore, self._ignoreErrors)
    542             self._oldCI, log._clearIgnores = (log._clearIgnores,
    543                                               self._clearIgnores)
     540            log._flushErrors = self.flushErrors
     541            log._ignore = self._ignoreErrors
     542            log._clearIgnores = self._clearIgnores
    544543        self._added += 1
    545544
     545
    546546    def _remove(self):
    547547        self._added -= 1
    548548        if self._added == 0:
    549549            log.removeObserver(self.gotEvent)
    550             log._flushErrors = self._oldFE
    551             log._ignore = self._oldIE
    552             log._clearIgnores = self._oldCI
    553550
    554551
    555552    def _ignoreErrors(self, *errorTypes):
  • twisted/python/log.py

     
    2222
    2323class ILogContext:
    2424    """
    25     Actually, this interface is just a synoym for the dictionary interface,
     25    Actually, this interface is just a synonym for the dictionary interface,
    2626    but it serves as a key for the default information in a log.
    2727
    28     I do not inherit from Interface because the world is a cruel place.
     28    I do not inherit from C{Interface} because the world is a cruel place.
    2929    """
    3030
    3131
     
    9393_keptErrors = []
    9494_ignoreErrors = []
    9595
    96 def startKeepingErrors():
    97     """
    98     DEPRECATED in Twisted 2.5.
    99 
    100     Support function for testing frameworks.
    101 
    102     Start keeping errors in a buffer which can be retrieved (and emptied) with
    103     flushErrors.
    104     """
    105     warnings.warn("log.startKeepingErrors is deprecated since Twisted 2.5",
    106                   category=DeprecationWarning, stacklevel=2)
    107     global _keepErrors
    108     _keepErrors = 1
    109 
    110 
    111 def flushErrors(*errorTypes):
    112     """
    113     DEPRECATED in Twisted 2.5.  See L{TestCase.flushLoggedErrors}.
    114 
    115     Support function for testing frameworks.
    116 
    117     Return a list of errors that occurred since the last call to flushErrors().
    118     (This will return None unless startKeepingErrors has been called.)
    119     """
    120 
    121     warnings.warn("log.flushErrors is deprecated since Twisted 2.5. "
    122                   "If you need to flush errors from within a unittest, "
    123                   "use TestCase.flushLoggedErrors instead.",
    124                   category=DeprecationWarning, stacklevel=2)
    125     return _flushErrors(*errorTypes)
    126 
    127 
    128 def _flushErrors(*errorTypes):
    129     """
    130     PRIVATE. DEPRECATED. DON'T USE.
    131     """
    132     global _keptErrors
    133     k = _keptErrors
    134     _keptErrors = []
    135     if errorTypes:
    136         for erk in k:
    137             shouldReLog = 1
    138             for errT in errorTypes:
    139                 if erk.check(errT):
    140                     shouldReLog = 0
    141             if shouldReLog:
    142                 err(erk)
    143     return k
    144 
    145 def ignoreErrors(*types):
    146     """
    147     DEPRECATED
    148     """
    149     warnings.warn("log.ignoreErrors is deprecated since Twisted 2.5",
    150                   category=DeprecationWarning, stacklevel=2)
    151     _ignore(*types)
    152 
    153 def _ignore(*types):
    154     """
    155     PRIVATE. DEPRECATED. DON'T USE.
    156     """
    157     for type in types:
    158         _ignoreErrors.append(type)
    159 
    160 def clearIgnores():
    161     """
    162     DEPRECATED
    163     """
    164     warnings.warn("log.clearIgnores is deprecated since Twisted 2.5",
    165                   category=DeprecationWarning, stacklevel=2)
    166     _clearIgnores()
    167 
    168 def _clearIgnores():
    169     """
    170     PRIVATE. DEPRECATED. DON'T USE.
    171     """
    172     global _ignoreErrors
    173     _ignoreErrors = []
    174 
    17596
    17697def err(_stuff=None, _why=None, **kw):
    17798    """
  • twisted/topfiles/5765.removal

     
     1startKeepingErrors, flushErrors, ignoreErrors, and clearIgnores in twisted.python.log (deprecated since Twisted 2.5) are removed now.