The inspect.signature() method was only added in Python 3.3. #31

This commit is contained in:
Graham Dumpleton
2014-10-12 14:46:32 +11:00
parent 411d1c45b2
commit 77a486e03c
3 changed files with 23 additions and 5 deletions

View File

@@ -1,6 +1,18 @@
Release Notes
=============
Version 1.9.1
-------------
**Bugs Fixed**
* The ``inspect.signature()`` function was only added in Python 3.3.
Use fallback when doesn't exist and on Python 3.2 or earlier Python 3
versions.
Note that testing is only performed for Python 3.3+, so it isn't
actually known if the ``wrapt`` package works on Python 3.2.
Version 1.9.0
-------------

View File

@@ -13,8 +13,10 @@ from inspect import getargspec, ismethod, isclass
from collections import namedtuple
from threading import Lock, RLock
if not PY2:
try:
from inspect import signature
except ImportError:
pass
from .wrappers import (FunctionWrapper, BoundFunctionWrapper, ObjectProxy,
CallableObjectProxy)
@@ -72,7 +74,7 @@ class _AdapterFunctionSurrogate(CallableObjectProxy):
@property
def __signature__(self):
if PY2:
if 'signature' not in globals():
return self._self_adapter.__signature__
else:
# Can't allow this to fail on Python 3 else it falls

View File

@@ -1,13 +1,17 @@
import pytest
from compat import PY2, PY3
import sys
version = tuple(sys.version_info[:2])
class DummyCollector(pytest.collect.File):
def collect(self):
return []
def pytest_pycollect_makemodule(path, parent):
if "py3" in path.basename and not PY3:
if '_py33' in path.basename and version < (3, 3):
return DummyCollector(path, parent=parent)
if "py2" in path.basename and not PY2:
if '_py3' in path.basename and version < (3, 0):
return DummyCollector(path, parent=parent)
if '_py2' in path.basename and version >= (3, 0):
return DummyCollector(path, parent=parent)