Ticket #5386: 5386.patch

File 5386.patch, 15.0 KB (added by rockstar, 2 years ago)

Remove mentions of Python 2.3 and code where applicable.

  • doc/core/development/policy/test-standard.xhtml

    === modified file 'doc/core/development/policy/test-standard.xhtml'
    old new  
    292292old code has decent coverage. Passing the <code>--coverage</code> option to 
    293293to Trial will generate the coverage information in a file called  
    294294<code>coverage</code> which can be found in the <code>_trial_temp</code> 
    295 folder. This option requires Python 2.3.3 or newer.</p> 
     295folder.</p> 
    296296 
    297297<h2>Associating Test Cases With Source Files</h2> 
    298298 
  • twisted/conch/test/test_cftp.py

    === modified file 'twisted/conch/test/test_cftp.py'
    old new  
    1414 
    1515_reason = None 
    1616if Crypto and pyasn1: 
    17     try: 
    18         from twisted.conch import unix 
    19         from twisted.conch.scripts import cftp 
    20         from twisted.conch.test.test_filetransfer import FileTransferForTestAvatar 
    21     except ImportError, e: 
    22         # Python 2.3 compatibility fix 
    23         sys.modules.pop("twisted.conch.unix", None) 
    24         unix = None 
    25         _reason = str(e) 
    26         del e 
     17    from twisted.conch import unix 
     18    from twisted.conch.scripts import cftp 
     19    from twisted.conch.test.test_filetransfer import FileTransferForTestAvatar 
    2720else: 
    2821    unix = None 
    2922 
  • twisted/lore/lint.py

    === modified file 'twisted/lore/lint.py'
    old new  
    1313from twisted.python import reflect 
    1414 
    1515 
    16 # parser.suite in Python 2.3 raises SyntaxError, <2.3 raises parser.ParserError 
    17 parserErrors = (SyntaxError, parser.ParserError) 
    18  
    1916class TagChecker: 
    2017 
    2118    def check(self, dom, filename): 
     
    131128                    text = '\n'.join(lines) + '\n' 
    132129                    try: 
    133130                        parser.suite(text) 
    134                     except parserErrors, e: 
     131                    except SyntaxError: 
    135132                        # Pretend the "..." idiom is syntactically valid 
    136133                        text = text.replace("...","'...'") 
    137134                        parser.suite(text) 
    138                 except parserErrors, e: 
     135                except SyntaxError, e: 
    139136                    self._reportError(filename, node, 
    140137                                      'invalid python code:' + str(e)) 
    141138 
  • twisted/python/_release.py

    === modified file 'twisted/python/_release.py'
    old new  
    424424    """ 
    425425    Generate API documentation from source files using 
    426426    U{pydoctor<http://codespeak.net/~mwh/pydoctor/>}.  This requires 
    427     pydoctor to be installed and usable (which means you won't be able to 
    428     use it with Python 2.3). 
     427    pydoctor to be installed and usable. 
    429428    """ 
    430429    def build(self, projectName, projectURL, sourceURL, packagePath, 
    431430              outputPath): 
  • twisted/python/reflect.py

    === modified file 'twisted/python/reflect.py'
    old new  
    438438    @raise _NoModuleFound: if no module was found. 
    439439    """ 
    440440    try: 
    441         try: 
    442             return __import__(importName) 
    443         except ImportError: 
    444             excType, excValue, excTraceback = sys.exc_info() 
    445             while excTraceback: 
    446                 execName = excTraceback.tb_frame.f_globals["__name__"] 
    447                 if (execName is None or # python 2.4+, post-cleanup 
    448                     execName == importName): # python 2.3, no cleanup 
    449                     raise excType, excValue, excTraceback 
    450                 excTraceback = excTraceback.tb_next 
    451             raise _NoModuleFound() 
    452     except: 
    453         # Necessary for cleaning up modules in 2.3. 
    454         sys.modules.pop(importName, None) 
    455         raise 
     441        return __import__(importName) 
     442    except ImportError: 
     443        excType, excValue, excTraceback = sys.exc_info() 
     444        while excTraceback: 
     445            execName = excTraceback.tb_frame.f_globals["__name__"] 
     446            if execName is None: 
     447                raise excType, excValue, excTraceback 
     448            excTraceback = excTraceback.tb_next 
     449        raise _NoModuleFound() 
    456450 
    457451 
    458452 
  • twisted/python/syslog.py

    === modified file 'twisted/python/syslog.py'
    old new  
    1212 
    1313from twisted.python import log 
    1414 
    15 # These defaults come from the Python 2.3 syslog docs. 
     15# These defaults come from the Python syslog docs. 
    1616DEFAULT_OPTIONS = 0 
    1717DEFAULT_FACILITY = syslog.LOG_USER 
    1818 
  • twisted/python/util.py

    === modified file 'twisted/python/util.py'
    old new  
    791791    representation makes sense. 
    792792 
    793793    This is mostly necessary in Python 2.4 which implements L{id} to sometimes 
    794     return a negative value.  Python 2.3 shares this behavior, but also 
    795     implements hex and the %x format specifier to represent negative values as 
    796     though they were positive ones, obscuring the behavior of L{id}.  Python 
    797     2.5's implementation of L{id} always returns positive values. 
     794    return a negative value.  Python 2.5's implementation of L{id} always 
     795    returns positive values. 
    798796    """ 
    799797    rval = _idFunction(obj) 
    800798    if rval < 0: 
     
    807805    Overwrite C{g}'s name and docstring with values from C{f}.  Update 
    808806    C{g}'s instance dictionary with C{f}'s. 
    809807 
    810     To use this function safely you must use the return value. In Python 2.3, 
    811     L{mergeFunctionMetadata} will create a new function. In later versions of 
    812     Python, C{g} will be mutated and returned. 
     808    To use this function safely you must use the return value. C{g} will 
     809    be mutated and returned. 
    813810 
    814811    @return: A function that has C{g}'s behavior and metadata merged from 
    815812        C{f}. 
     
    817814    try: 
    818815        g.__name__ = f.__name__ 
    819816    except TypeError: 
    820         try: 
    821             merged = types.FunctionType( 
    822                 g.func_code, g.func_globals, 
    823                 f.__name__, inspect.getargspec(g)[-1], 
    824                 g.func_closure) 
    825         except TypeError: 
    826             pass 
     817        pass 
    827818    else: 
    828819        merged = g 
    829820    try: 
  • twisted/spread/jelly.py

    === modified file 'twisted/spread/jelly.py'
    old new  
    5454The C{set} builtin and the C{sets.Set} class are serialized to the same 
    5555thing, and unserialized to C{set} if available, else to C{sets.Set}. It means 
    5656that there's a possibility of type switching in the serialization process. The 
    57 solution is to always use C{set} if possible, and only use C{sets.Set} under 
    58 Python 2.3; this can be accomplished by using L{twisted.python.compat.set}. 
     57solution is to always use C{set} if possible; this can be accomplished by using L{twisted.python.compat.set}. 
    5958 
    6059The same rule applies for C{frozenset} and C{sets.ImmutableSet}. 
    6160 
  • twisted/test/test_reflect.py

    === modified file 'twisted/test/test_reflect.py'
    old new  
    217217        self.assertRaises( 
    218218            ZeroDivisionError, 
    219219            reflect.namedAny, "twisted.test.reflect_helper_ZDE") 
    220         # Make sure that this behavior is *consistent* for 2.3, where there is 
    221         # no post-failed-import cleanup 
    222220        self.assertRaises( 
    223221            ZeroDivisionError, 
    224222            reflect.namedAny, "twisted.test.reflect_helper_ZDE") 
     
    413411        self.assertEqual(['[0]', '[1][0]'], reflect.objgrep(d, a, reflect.isSame, maxDepth=2)) 
    414412        self.assertEqual(['[0]', '[1][0]', '[1][1][0]'], reflect.objgrep(d, a, reflect.isSame, maxDepth=3)) 
    415413 
    416     def test_deque(self): 
    417         """ 
    418         Test references search through a deque object. Only for Python > 2.3. 
    419         """ 
    420         o = object() 
    421         D = deque() 
    422         D.append(None) 
    423         D.append(o) 
    424  
    425         self.assertIn("[1]", reflect.objgrep(D, o, reflect.isSame)) 
    426  
    427     if deque is None: 
    428         test_deque.skip = "Deque not available" 
    429  
    430414 
    431415class GetClass(unittest.TestCase): 
    432416    def testOld(self): 
  • twisted/trial/runner.py

    === modified file 'twisted/trial/runner.py'
    old new  
    189189    DEPRECATED in Twisted 8.0. 
    190190 
    191191    This class decorates the pyunit.TestCase class, mainly to work around the 
    192     differences between unittest in Python 2.3, 2.4, and 2.5. These 
     192    differences between unittest in Python 2.4, and 2.5. These 
    193193    differences are:: 
    194194 
    195195        - The way doctest unittests describe themselves 
     
    239239 
    240240 
    241241 
    242 class DocTestCase(PyUnitTestCase): 
    243     """ 
    244     DEPRECATED in Twisted 8.0. 
    245     """ 
    246  
    247     def id(self): 
    248         """ 
    249         In Python 2.4, doctests have correct id() behaviour. In Python 2.3, 
    250         id() returns 'runit'. 
    251  
    252         Here we override id() so that at least it will always contain the 
    253         fully qualified Python name of the doctest. 
    254         """ 
    255         return self._test.shortDescription() 
    256  
    257  
    258242class TrialSuite(TestSuite): 
    259243    """ 
    260244    Suite to wrap around every single test in a C{trial} run. Used internally 
  • twisted/trial/test/test_doctest.py

    === modified file 'twisted/trial/test/test_doctest.py'
    old new  
    1414    Tests for Twisted's doctest support. 
    1515    """ 
    1616 
    17     def test_id(self): 
    18         """ 
    19         Check that the id() of the doctests' case object contains the FQPN of 
    20         the actual tests. We need this because id() has weird behaviour w/ 
    21         doctest in Python 2.3. 
    22         """ 
    23         loader = runner.TestLoader() 
    24         suite = loader.loadDoctests(mockdoctest) 
    25         idPrefix = 'twisted.trial.test.mockdoctest.Counter' 
    26         for test in suite._tests: 
    27             self.assertIn(idPrefix, itrial.ITestCase(test).id()) 
    28  
    29  
    3017    def test_basicTrialIntegration(self): 
    3118        """ 
    3219        L{loadDoctests} loads all of the doctests in the given module. 
     
    4330        result = reporter.TestResult() 
    4431        suite.run(result) 
    4532        self.assertEqual(5, result.successes) 
    46         # doctest reports failures as errors in 2.3 
    47         self.assertEqual(2, len(result.errors) + len(result.failures)) 
     33        self.assertEqual(2, len(result.failures)) 
    4834 
    4935 
    5036    def test_expectedResults(self, count=1): 
  • twisted/trial/test/test_loader.py

    === modified file 'twisted/trial/test/test_loader.py'
    old new  
    510510 
    511511 
    512512class PackageOrderingTest(packages.SysPathManglingTest): 
    513     if sys.version_info < (2, 4): 
    514         skip = ( 
    515             "Python 2.3 import semantics make this behavior incorrect on that " 
    516             "version of Python as well as difficult to test.  The second " 
    517             "import of a package which raised an exception the first time it " 
    518             "was imported will succeed on Python 2.3, whereas it will fail on " 
    519             "later versions of Python.  Trial does not account for this, so " 
    520             "this test fails with inconsistencies between the expected and " 
    521             "the received loader errors.") 
    522513 
    523514    def setUp(self): 
    524515        self.loader = runner.TestLoader() 
  • twisted/trial/unittest.py

    === modified file 'twisted/trial/unittest.py'
    old new  
    14011401        return self.run(result) 
    14021402 
    14031403 
    1404     def run(self, result): 
    1405         """ 
    1406         Call C{run} on every member of the suite. 
    1407         """ 
    1408         # we implement this because Python 2.3 unittest defines this code 
    1409         # in __call__, whereas 2.4 defines the code in run. 
    1410         for test in self._tests: 
    1411             if result.shouldStop: 
    1412                 break 
    1413             test(result) 
    1414         return result 
    1415  
    1416  
    1417  
    14181404class TestDecorator(components.proxyForInterface(itrial.ITestCase, 
    14191405                                                 "_originalTest")): 
    14201406    """ 
     
    15701556 
    15711557 
    15721558 
    1573 # Support for Python 2.3 
    1574 try: 
    1575     iter(pyunit.TestSuite()) 
    1576 except TypeError: 
    1577     # Python 2.3's TestSuite doesn't support iteration. Let's monkey patch it! 
    1578     def __iter__(self): 
    1579         return iter(self._tests) 
    1580     pyunit.TestSuite.__iter__ = __iter__ 
     1559iter(pyunit.TestSuite()) 
    15811560 
    15821561 
    15831562 
  • twisted/web/http_headers.py

    === modified file 'twisted/web/http_headers.py'
    old new  
    7878        return dict(self.items()) 
    7979 
    8080 
    81     # Python 2.3 DictMixin.setdefault is defined so as not to have a default 
    82     # for the value parameter.  This is necessary to make this setdefault look 
    83     # like dict.setdefault on Python 2.3. -exarkun 
    84     def setdefault(self, name, value=None): 
    85         """ 
    86         Retrieve the last value for the given header name.  If there are no 
    87         values present for that header, set the value to C{value} and return 
    88         that instead.  Note that C{None} is the default for C{value} for 
    89         backwards compatibility, but header values may only be of type C{str}. 
    90         """ 
    91         return DictMixin.setdefault(self, name, value) 
    92  
    93  
    9481    # The remaining methods are only for efficiency.  The same behavior 
    9582    # should remain even if they are removed.  For details, see 
    9683    # <http://docs.python.org/lib/module-UserDict.html>. 
  • twisted/words/protocols/jabber/sasl.py

    === modified file 'twisted/words/protocols/jabber/sasl.py'
    old new  
    55XMPP-specific SASL profile. 
    66""" 
    77 
     8from base64 import b64decode, b64encode 
    89import re 
    910from twisted.internet import defer 
    1011from twisted.words.protocols.jabber import sasl_mechanisms, xmlstream 
    1112from twisted.words.xish import domish 
    1213 
    13 # The b64decode and b64encode functions from the base64 module are new in 
    14 # Python 2.4. For Python 2.3 compatibility, the legacy interface is used while 
    15 # working around MIMEisms. 
    16  
    17 try: 
    18     from base64 import b64decode, b64encode 
    19 except ImportError: 
    20     import base64 
    21  
    22     def b64encode(s): 
    23         return "".join(base64.encodestring(s).split("\n")) 
    24  
    25     b64decode = base64.decodestring 
    26  
    2714NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl' 
    2815 
    2916def get_mechanisms(xs): 
  • twisted/words/protocols/jabber/xmpp_stringprep.py

    === modified file 'twisted/words/protocols/jabber/xmpp_stringprep.py'
    old new  
    2020 
    2121    warnings.warn("Accented and non-Western Jabber IDs will not be properly " 
    2222                  "case-folded with this version of Python, resulting in " 
    23                   "incorrect protocol-level behavior.  It is strongly " 
    24                   "recommended you upgrade to Python 2.3.2 or newer if you " 
    25                   "intend to use Twisted's Jabber support.") 
     23                  "incorrect protocol-level behavior.") 
    2624 
    2725else: 
    2826    import stringprep