Ticket #6166: ticket6166.patch

File ticket6166.patch, 12.1 KB (added by Can Ibanoglu, 8 years ago)

Deprecation of getstate and setstate along with new test which check for deprecation

  • twisted/internet/_sslverify.py

    Only in Twisted-13.0.0: .DS_Store
    Only in Twisted-13.0.0: _trial_temp
    Only in Twisted-13.0.0/twisted: .DS_Store
    Only in Twisted-13.0.0/twisted: __init__.pyc
    Only in Twisted-13.0.0/twisted: _version.pyc
    Only in Twisted-13.0.0/twisted/application: __init__.pyc
    Only in Twisted-13.0.0/twisted/application: app.pyc
    Only in Twisted-13.0.0/twisted/application: reactors.pyc
    Only in Twisted-13.0.0/twisted/application: service.pyc
    Only in Twisted-13.0.0/twisted/conch: __init__.pyc
    Only in Twisted-13.0.0/twisted/conch: _version.pyc
    Only in Twisted-13.0.0/twisted/conch: checkers.pyc
    Only in Twisted-13.0.0/twisted/conch: error.pyc
    Only in Twisted-13.0.0/twisted/conch/ssh: __init__.pyc
    Only in Twisted-13.0.0/twisted/conch/ssh: keys.pyc
    Only in Twisted-13.0.0/twisted: copyright.pyc
    Only in Twisted-13.0.0/twisted/cred: __init__.pyc
    Only in Twisted-13.0.0/twisted/cred: _digest.pyc
    Only in Twisted-13.0.0/twisted/cred: checkers.pyc
    Only in Twisted-13.0.0/twisted/cred: credentials.pyc
    Only in Twisted-13.0.0/twisted/cred: error.pyc
    Only in Twisted-13.0.0/twisted/cred: pamauth.pyc
    Only in Twisted-13.0.0/twisted/cred: strcred.pyc
    Only in Twisted-13.0.0/twisted/internet: __init__.pyc
    Only in Twisted-13.0.0/twisted/internet: _baseprocess.pyc
    Only in Twisted-13.0.0/twisted/internet: _newtls.pyc
    Only in Twisted-13.0.0/twisted/internet: _posixstdio.pyc
    Only in Twisted-13.0.0/twisted/internet: _signals.pyc
    diff -ur Twisted-13.0.0/twisted/internet/_sslverify.py Twisted-13.0.0-2/twisted/internet/_sslverify.py
    old new  
    1515from twisted.internet.defer import Deferred
    1616from twisted.internet.error import VerifyError, CertificateError
    1717
    18 from twisted.python.versions import Version
    19 from twisted.python.deprecate import getDeprecationWarningString
    20 import warnings
    21 
    2218def _sessionCounter(counter=itertools.count()):
    2319    """
    2420    Private - shared between all OpenSSLCertificateOptions, counts up to
     
    512508    def dump(self, format=crypto.FILETYPE_ASN1):
    513509        return crypto.dump_privatekey(format, self.original)
    514510
     511
    515512    def __getstate__(self):
    516         """
    517         Deprecated; see ticket #6166.
    518         """
    519         msg = getDeprecationWarningString(
    520             self.__getstate__, Version("Twisted", 13, 1, 0))
    521         warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
    522513        return self.dump()
    523514
     515
    524516    def __setstate__(self, state):
    525         """
    526         Deprecated; see ticket #6166.
    527         """
    528         msg = getDeprecationWarningString(
    529             self.__setstate__, Version("Twisted", 13, 1, 0))
    530         warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
    531517        self.__init__(crypto.load_privatekey(crypto.FILETYPE_ASN1, state))
    532518
    533519
     
    732718        self.fixBrokenPeers = fixBrokenPeers
    733719        self.enableSessionTickets = enableSessionTickets
    734720
     721
    735722    def __getstate__(self):
    736         """
    737         Deprecated; see ticket #6166.
    738         """
    739         msg = getDeprecationWarningString(
    740             self.__getstate__, Version("Twisted", 13, 1, 0))
    741         warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
    742723        d = self.__dict__.copy()
    743724        try:
    744725            del d['_context']
     
    746727            pass
    747728        return d
    748729
     730
    749731    def __setstate__(self, state):
    750         """
    751         Deprecated; see ticket #6166.
    752         """
    753         msg = getDeprecationWarningString(
    754             self.__setstate__, Version("Twisted", 13, 1, 0))
    755         warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
    756732        self.__dict__ = state
    757733
    758734
  • twisted/test/test_sslverify.py

    Only in Twisted-13.0.0/twisted/internet: _sslverify.pyc
    Only in Twisted-13.0.0/twisted/internet: _utilspy3.pyc
    Only in Twisted-13.0.0/twisted/internet: abstract.pyc
    Only in Twisted-13.0.0/twisted/internet: address.pyc
    Only in Twisted-13.0.0/twisted/internet: base.pyc
    Only in Twisted-13.0.0/twisted/internet: default.pyc
    Only in Twisted-13.0.0/twisted/internet: defer.pyc
    Only in Twisted-13.0.0/twisted/internet: endpoints.pyc
    Only in Twisted-13.0.0/twisted/internet: error.pyc
    Only in Twisted-13.0.0/twisted/internet: fdesc.pyc
    Only in Twisted-13.0.0/twisted/internet: interfaces.pyc
    Only in Twisted-13.0.0/twisted/internet: main.pyc
    Only in Twisted-13.0.0/twisted/internet: posixbase.pyc
    Only in Twisted-13.0.0/twisted/internet: process.pyc
    Only in Twisted-13.0.0/twisted/internet: protocol.pyc
    Only in Twisted-13.0.0/twisted/internet: reactor.pyc
    Only in Twisted-13.0.0/twisted/internet: selectreactor.pyc
    Only in Twisted-13.0.0/twisted/internet: stdio.pyc
    Only in Twisted-13.0.0/twisted/internet: task.pyc
    Only in Twisted-13.0.0/twisted/internet: tcp.pyc
    Only in Twisted-13.0.0/twisted/internet: threads.pyc
    Only in Twisted-13.0.0/twisted/internet: udp.pyc
    Only in Twisted-13.0.0/twisted/internet: win32eventreactor.pyc
    Only in Twisted-13.0.0/twisted/lore: __init__.pyc
    Only in Twisted-13.0.0/twisted/lore: _version.pyc
    Only in Twisted-13.0.0/twisted/lore: htmlbook.pyc
    Only in Twisted-13.0.0/twisted/lore: indexer.pyc
    Only in Twisted-13.0.0/twisted/lore: latex.pyc
    Only in Twisted-13.0.0/twisted/lore: numberer.pyc
    Only in Twisted-13.0.0/twisted/lore: process.pyc
    Only in Twisted-13.0.0/twisted/lore/scripts: __init__.pyc
    Only in Twisted-13.0.0/twisted/lore/scripts: lore.pyc
    Only in Twisted-13.0.0/twisted/lore: tree.pyc
    Only in Twisted-13.0.0/twisted/persisted: __init__.pyc
    Only in Twisted-13.0.0/twisted/persisted: sob.pyc
    Only in Twisted-13.0.0/twisted/persisted: styles.pyc
    Only in Twisted-13.0.0/twisted: plugin.pyc
    Only in Twisted-13.0.0/twisted/plugins: __init__.pyc
    Only in Twisted-13.0.0/twisted/plugins: cred_anonymous.pyc
    Only in Twisted-13.0.0/twisted/plugins: cred_file.pyc
    Only in Twisted-13.0.0/twisted/plugins: cred_memory.pyc
    Only in Twisted-13.0.0/twisted/plugins: cred_sshkeys.pyc
    Only in Twisted-13.0.0/twisted/plugins: cred_unix.pyc
    Only in Twisted-13.0.0/twisted/plugins: dropin.cache
    Only in Twisted-13.0.0/twisted/plugins: twisted_conch.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_core.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_ftp.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_inet.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_lore.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_mail.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_manhole.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_names.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_news.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_portforward.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_qtstub.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_reactors.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_runner.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_socks.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_telnet.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_trial.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_web.pyc
    Only in Twisted-13.0.0/twisted/plugins: twisted_words.pyc
    Only in Twisted-13.0.0/twisted/protocols: __init__.pyc
    Only in Twisted-13.0.0/twisted/protocols: policies.pyc
    Only in Twisted-13.0.0/twisted/protocols: tls.pyc
    Only in Twisted-13.0.0/twisted/python: .DS_Store
    Only in Twisted-13.0.0/twisted/python: __init__.pyc
    Only in Twisted-13.0.0/twisted/python: _reflectpy3.pyc
    Only in Twisted-13.0.0/twisted/python: compat.pyc
    Only in Twisted-13.0.0/twisted/python: components.pyc
    Only in Twisted-13.0.0/twisted/python: context.pyc
    Only in Twisted-13.0.0/twisted/python: deprecate.pyc
    Only in Twisted-13.0.0/twisted/python: failure.pyc
    Only in Twisted-13.0.0/twisted/python: filepath.pyc
    Only in Twisted-13.0.0/twisted/python: hashlib.pyc
    Only in Twisted-13.0.0/twisted/python: htmlizer.pyc
    Only in Twisted-13.0.0/twisted/python: lockfile.pyc
    Only in Twisted-13.0.0/twisted/python: log.pyc
    Only in Twisted-13.0.0/twisted/python: logfile.pyc
    Only in Twisted-13.0.0/twisted/python: modules.pyc
    Only in Twisted-13.0.0/twisted/python: monkey.pyc
    Only in Twisted-13.0.0/twisted/python: procutils.pyc
    Only in Twisted-13.0.0/twisted/python: randbytes.pyc
    Only in Twisted-13.0.0/twisted/python: reflect.pyc
    Only in Twisted-13.0.0/twisted/python: runtime.pyc
    Only in Twisted-13.0.0/twisted/python: systemd.pyc
    Only in Twisted-13.0.0/twisted/python: text.pyc
    Only in Twisted-13.0.0/twisted/python: threadable.pyc
    Only in Twisted-13.0.0/twisted/python: usage.pyc
    Only in Twisted-13.0.0/twisted/python: util.pyc
    Only in Twisted-13.0.0/twisted/python: versions.pyc
    Only in Twisted-13.0.0/twisted/python: win32.pyc
    Only in Twisted-13.0.0/twisted/python: zippath.pyc
    Only in Twisted-13.0.0/twisted/scripts: __init__.pyc
    Only in Twisted-13.0.0/twisted/scripts: trial.pyc
    Only in Twisted-13.0.0/twisted/test: __init__.pyc
    diff -ur Twisted-13.0.0/twisted/test/test_sslverify.py Twisted-13.0.0-2/twisted/test/test_sslverify.py
    old new  
    1515    from OpenSSL.crypto import PKey, X509, X509Req
    1616    from OpenSSL.crypto import TYPE_RSA
    1717    from twisted.internet import _sslverify as sslverify
    18     from twisted.python.versions import Version
    1918except ImportError:
    2019    pass
    2120
     
    539538        return onData.addCallback(
    540539                lambda result: self.assertEqual(result, WritingProtocol.byte))
    541540
    542     def test_getstateDeprecation(self):
    543         """
    544         Test deprecation of L{_sslverify.OpenSSLCertificateOptions.__getstate__}
    545         """
    546         opts = sslverify.OpenSSLCertificateOptions()
    547         self.callDeprecated(
    548             Version("Twisted", 13, 1, 0),
    549             opts.__getstate__)
    550 
    551     def test_setstateDeprecation(self):
    552         """
    553         Test deprecation of L{_sslverify.OpenSSLCertificateOptions.__setstate__}
    554         """
    555         opts = sslverify.OpenSSLCertificateOptions()
    556         state = opts.__getstate__()
    557         self.callDeprecated(
    558             Version("Twisted", 13, 1, 0),
    559             opts.__setstate__, state)
    560 
    561541
    562542
    563543if interfaces.IReactorSSL(reactor, None) is None:
    564544    OpenSSLOptions.skip = "Reactor does not support SSL, cannot run SSL tests"
    565545
    566 class KeyPair(unittest.TestCase):
    567     """
    568     Tests for L{_sslverify.KeyPair}
    569     """
    570 
    571     def test_getstateDeprecation(self):
    572         """
    573         Test deprecation of L{_sslverify.KeyPair.__getstate__}
    574         """
    575         sKey = makeCertificate(
    576             O=b"Server Test Certificate",
    577             CN=b"server")[0]
    578         keypair = sslverify.KeyPair(sKey)
    579         self.callDeprecated(
    580             Version("Twisted", 13, 1, 0),
    581             keypair.__getstate__)
    582 
    583     def test_setstateDeprecation(self):
    584         """
    585         Test deprecation of L{_sslverify.KeyPair.__setstate__}
    586         """
    587         sKey = makeCertificate(
    588             O=b"Server Test Certificate",
    589             CN=b"server")[0]
    590         keypair = sslverify.KeyPair(sKey)
    591         state = keypair.__getstate__()
    592         self.callDeprecated(
    593             Version("Twisted", 13, 1, 0),
    594             keypair.__setstate__, state)
    595 
    596546
    597547
    598548class _NotSSLTransport:
     
    684634            12346)
    685635
    686636
     637
    687638if interfaces.IReactorSSL(reactor, None) is None:
    688639    Constructors.skip = "Reactor does not support SSL, cannot run SSL tests"