prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Python 3.6 incompatibility because of getargspec
  Hi, on testing pywikibot on 3.6 I noticed that your package uses `inspect.getargspec` which has been removed in 3.6 after it has been deprecated in 3.5 (although the documentation mentions it has been deprecated since Python 3).
  
  I know that Python 3.6 hasn't been released yet but I just wanted to let you know so you have enough time to prevent issues before it is released.
  
  Here the Travis build: https://travis-ci.org/xZise/pywikibot-core/jobs/82446934
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cryptography/utils.py`
  Content:
  ```
  1 # This file is dual licensed under the terms of the Apache License, Version
  2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3 # for complete details.
  4 
  5 from __future__ import absolute_import, division, print_function
  6 
  7 import abc
  8 import binascii
  9 import inspect
  10 import struct
  11 import sys
  12 import warnings
  13 
  14 
  15 DeprecatedIn09 = DeprecationWarning
  16 DeprecatedIn10 = PendingDeprecationWarning
  17 
  18 
  19 def read_only_property(name):
  20     return property(lambda self: getattr(self, name))
  21 
  22 
  23 def register_interface(iface):
  24     def register_decorator(klass):
  25         verify_interface(iface, klass)
  26         iface.register(klass)
  27         return klass
  28     return register_decorator
  29 
  30 
  31 if hasattr(int, "from_bytes"):
  32     int_from_bytes = int.from_bytes
  33 else:
  34     def int_from_bytes(data, byteorder, signed=False):
  35         assert byteorder == 'big'
  36         assert not signed
  37 
  38         if len(data) % 4 != 0:
  39             data = (b'\x00' * (4 - (len(data) % 4))) + data
  40 
  41         result = 0
  42 
  43         while len(data) > 0:
  44             digit, = struct.unpack('>I', data[:4])
  45             result = (result << 32) + digit
  46             data = data[4:]
  47 
  48         return result
  49 
  50 
  51 def int_to_bytes(integer):
  52     hex_string = '%x' % integer
  53     n = len(hex_string)
  54     return binascii.unhexlify(hex_string.zfill(n + (n & 1)))
  55 
  56 
  57 class InterfaceNotImplemented(Exception):
  58     pass
  59 
  60 
  61 def verify_interface(iface, klass):
  62     for method in iface.__abstractmethods__:
  63         if not hasattr(klass, method):
  64             raise InterfaceNotImplemented(
  65                 "{0} is missing a {1!r} method".format(klass, method)
  66             )
  67         if isinstance(getattr(iface, method), abc.abstractproperty):
  68             # Can't properly verify these yet.
  69             continue
  70         spec = inspect.getargspec(getattr(iface, method))
  71         actual = inspect.getargspec(getattr(klass, method))
  72         if spec != actual:
  73             raise InterfaceNotImplemented(
  74                 "{0}.{1}'s signature differs from the expected. Expected: "
  75                 "{2!r}. Received: {3!r}".format(
  76                     klass, method, spec, actual
  77                 )
  78             )
  79 
  80 
  81 if sys.version_info >= (2, 7):
  82     def bit_length(x):
  83         return x.bit_length()
  84 else:
  85     def bit_length(x):
  86         return len(bin(x)) - (2 + (x <= 0))
  87 
  88 
  89 class _DeprecatedValue(object):
  90     def __init__(self, value, message, warning_class):
  91         self.value = value
  92         self.message = message
  93         self.warning_class = warning_class
  94 
  95 
  96 class _ModuleWithDeprecations(object):
  97     def __init__(self, module):
  98         self.__dict__["_module"] = module
  99 
  100     def __getattr__(self, attr):
  101         obj = getattr(self._module, attr)
  102         if isinstance(obj, _DeprecatedValue):
  103             warnings.warn(obj.message, obj.warning_class, stacklevel=2)
  104             obj = obj.value
  105         return obj
  106 
  107     def __setattr__(self, attr, value):
  108         setattr(self._module, attr, value)
  109 
  110     def __dir__(self):
  111         return ["_module"] + dir(self._module)
  112 
  113 
  114 def deprecated(value, module_name, message, warning_class):
  115     module = sys.modules[module_name]
  116     if not isinstance(module, _ModuleWithDeprecations):
  117         sys.modules[module_name] = module = _ModuleWithDeprecations(module)
  118     return _DeprecatedValue(value, message, warning_class)
  119
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
  --- a/src/cryptography/utils.py
  +++ b/src/cryptography/utils.py
  @@ -58,6 +58,12 @@
       pass
   
   
  +if hasattr(inspect, "signature"):
  +    signature = inspect.signature
  +else:
  +    signature = inspect.getargspec
  +
  +
   def verify_interface(iface, klass):
       for method in iface.__abstractmethods__:
           if not hasattr(klass, method):
  @@ -67,13 +73,13 @@
           if isinstance(getattr(iface, method), abc.abstractproperty):
               # Can't properly verify these yet.
               continue
  -        spec = inspect.getargspec(getattr(iface, method))
  -        actual = inspect.getargspec(getattr(klass, method))
  -        if spec != actual:
  +        sig = signature(getattr(iface, method))
  +        actual = signature(getattr(klass, method))
  +        if sig != actual:
               raise InterfaceNotImplemented(
                   "{0}.{1}'s signature differs from the expected. Expected: "
                   "{2!r}. Received: {3!r}".format(
  -                    klass, method, spec, actual
  +                    klass, method, sig, actual
                   )
               )
  
verification_info: {"golden_diff": "diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py\n--- a/src/cryptography/utils.py\n+++ b/src/cryptography/utils.py\n@@ -58,6 +58,12 @@\n     pass\n \n \n+if hasattr(inspect, \"signature\"):\n+    signature = inspect.signature\n+else:\n+    signature = inspect.getargspec\n+\n+\n def verify_interface(iface, klass):\n     for method in iface.__abstractmethods__:\n         if not hasattr(klass, method):\n@@ -67,13 +73,13 @@\n         if isinstance(getattr(iface, method), abc.abstractproperty):\n             # Can't properly verify these yet.\n             continue\n-        spec = inspect.getargspec(getattr(iface, method))\n-        actual = inspect.getargspec(getattr(klass, method))\n-        if spec != actual:\n+        sig = signature(getattr(iface, method))\n+        actual = signature(getattr(klass, method))\n+        if sig != actual:\n             raise InterfaceNotImplemented(\n                 \"{0}.{1}'s signature differs from the expected. Expected: \"\n                 \"{2!r}. Received: {3!r}\".format(\n-                    klass, method, spec, actual\n+                    klass, method, sig, actual\n                 )\n             )\n", "issue": "Python 3.6 incompatibility because of getargspec\nHi, on testing pywikibot on 3.6 I noticed that your package uses `inspect.getargspec` which has been removed in 3.6 after it has been deprecated in 3.5 (although the documentation mentions it has been deprecated since Python 3).\n\nI know that Python 3.6 hasn't been released yet but I just wanted to let you know so you have enough time to prevent issues before it is released.\n\nHere the Travis build: https://travis-ci.org/xZise/pywikibot-core/jobs/82446934\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\nimport binascii\nimport inspect\nimport struct\nimport sys\nimport warnings\n\n\nDeprecatedIn09 = DeprecationWarning\nDeprecatedIn10 = PendingDeprecationWarning\n\n\ndef read_only_property(name):\n    return property(lambda self: getattr(self, name))\n\n\ndef register_interface(iface):\n    def register_decorator(klass):\n        verify_interface(iface, klass)\n        iface.register(klass)\n        return klass\n    return register_decorator\n\n\nif hasattr(int, \"from_bytes\"):\n    int_from_bytes = int.from_bytes\nelse:\n    def int_from_bytes(data, byteorder, signed=False):\n        assert byteorder == 'big'\n        assert not signed\n\n        if len(data) % 4 != 0:\n            data = (b'\\x00' * (4 - (len(data) % 4))) + data\n\n        result = 0\n\n        while len(data) > 0:\n            digit, = struct.unpack('>I', data[:4])\n            result = (result << 32) + digit\n            data = data[4:]\n\n        return result\n\n\ndef int_to_bytes(integer):\n    hex_string = '%x' % integer\n    n = len(hex_string)\n    return binascii.unhexlify(hex_string.zfill(n + (n & 1)))\n\n\nclass InterfaceNotImplemented(Exception):\n    pass\n\n\ndef verify_interface(iface, klass):\n    for method in iface.__abstractmethods__:\n        if not hasattr(klass, method):\n            raise InterfaceNotImplemented(\n                \"{0} is missing a {1!r} method\".format(klass, method)\n            )\n        if isinstance(getattr(iface, method), abc.abstractproperty):\n            # Can't properly verify these yet.\n            continue\n        spec = inspect.getargspec(getattr(iface, method))\n        actual = inspect.getargspec(getattr(klass, method))\n        if spec != actual:\n            raise InterfaceNotImplemented(\n                \"{0}.{1}'s signature differs from the expected. Expected: \"\n                \"{2!r}. Received: {3!r}\".format(\n                    klass, method, spec, actual\n                )\n            )\n\n\nif sys.version_info >= (2, 7):\n    def bit_length(x):\n        return x.bit_length()\nelse:\n    def bit_length(x):\n        return len(bin(x)) - (2 + (x <= 0))\n\n\nclass _DeprecatedValue(object):\n    def __init__(self, value, message, warning_class):\n        self.value = value\n        self.message = message\n        self.warning_class = warning_class\n\n\nclass _ModuleWithDeprecations(object):\n    def __init__(self, module):\n        self.__dict__[\"_module\"] = module\n\n    def __getattr__(self, attr):\n        obj = getattr(self._module, attr)\n        if isinstance(obj, _DeprecatedValue):\n            warnings.warn(obj.message, obj.warning_class, stacklevel=2)\n            obj = obj.value\n        return obj\n\n    def __setattr__(self, attr, value):\n        setattr(self._module, attr, value)\n\n    def __dir__(self):\n        return [\"_module\"] + dir(self._module)\n\n\ndef deprecated(value, module_name, message, warning_class):\n    module = sys.modules[module_name]\n    if not isinstance(module, _ModuleWithDeprecations):\n        sys.modules[module_name] = module = _ModuleWithDeprecations(module)\n    return _DeprecatedValue(value, message, warning_class)\n", "path": "src/cryptography/utils.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\nimport binascii\nimport inspect\nimport struct\nimport sys\nimport warnings\n\n\nDeprecatedIn09 = DeprecationWarning\nDeprecatedIn10 = PendingDeprecationWarning\n\n\ndef read_only_property(name):\n    return property(lambda self: getattr(self, name))\n\n\ndef register_interface(iface):\n    def register_decorator(klass):\n        verify_interface(iface, klass)\n        iface.register(klass)\n        return klass\n    return register_decorator\n\n\nif hasattr(int, \"from_bytes\"):\n    int_from_bytes = int.from_bytes\nelse:\n    def int_from_bytes(data, byteorder, signed=False):\n        assert byteorder == 'big'\n        assert not signed\n\n        if len(data) % 4 != 0:\n            data = (b'\\x00' * (4 - (len(data) % 4))) + data\n\n        result = 0\n\n        while len(data) > 0:\n            digit, = struct.unpack('>I', data[:4])\n            result = (result << 32) + digit\n            data = data[4:]\n\n        return result\n\n\ndef int_to_bytes(integer):\n    hex_string = '%x' % integer\n    n = len(hex_string)\n    return binascii.unhexlify(hex_string.zfill(n + (n & 1)))\n\n\nclass InterfaceNotImplemented(Exception):\n    pass\n\n\nif hasattr(inspect, \"signature\"):\n    signature = inspect.signature\nelse:\n    signature = inspect.getargspec\n\n\ndef verify_interface(iface, klass):\n    for method in iface.__abstractmethods__:\n        if not hasattr(klass, method):\n            raise InterfaceNotImplemented(\n                \"{0} is missing a {1!r} method\".format(klass, method)\n            )\n        if isinstance(getattr(iface, method), abc.abstractproperty):\n            # Can't properly verify these yet.\n            continue\n        sig = signature(getattr(iface, method))\n        actual = signature(getattr(klass, method))\n        if sig != actual:\n            raise InterfaceNotImplemented(\n                \"{0}.{1}'s signature differs from the expected. Expected: \"\n                \"{2!r}. Received: {3!r}\".format(\n                    klass, method, sig, actual\n                )\n            )\n\n\nif sys.version_info >= (2, 7):\n    def bit_length(x):\n        return x.bit_length()\nelse:\n    def bit_length(x):\n        return len(bin(x)) - (2 + (x <= 0))\n\n\nclass _DeprecatedValue(object):\n    def __init__(self, value, message, warning_class):\n        self.value = value\n        self.message = message\n        self.warning_class = warning_class\n\n\nclass _ModuleWithDeprecations(object):\n    def __init__(self, module):\n        self.__dict__[\"_module\"] = module\n\n    def __getattr__(self, attr):\n        obj = getattr(self._module, attr)\n        if isinstance(obj, _DeprecatedValue):\n            warnings.warn(obj.message, obj.warning_class, stacklevel=2)\n            obj = obj.value\n        return obj\n\n    def __setattr__(self, attr, value):\n        setattr(self._module, attr, value)\n\n    def __dir__(self):\n        return [\"_module\"] + dir(self._module)\n\n\ndef deprecated(value, module_name, message, warning_class):\n    module = sys.modules[module_name]\n    if not isinstance(module, _ModuleWithDeprecations):\n        sys.modules[module_name] = module = _ModuleWithDeprecations(module)\n    return _DeprecatedValue(value, message, warning_class)\n", "path": "src/cryptography/utils.py"}]}