summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2015-02-05 22:24:11 -0600
committerMichael Merickel <michael@merickel.org>2015-02-05 22:24:11 -0600
commite82a99ee9a69504af88c84f39f325d25baae9fe6 (patch)
tree13f9c3ff1cbff743d25eb5cd451facf0a2f0494c
parent686f03bab3df9e1527dce1b02bcca1b05fc74bf5 (diff)
parentd6ff994619d18981dbde6dce7e8a10140f063e06 (diff)
downloadpyramid-e82a99ee9a69504af88c84f39f325d25baae9fe6.tar.gz
pyramid-e82a99ee9a69504af88c84f39f325d25baae9fe6.tar.bz2
pyramid-e82a99ee9a69504af88c84f39f325d25baae9fe6.zip
Merge pull request #1556 from everilae/master
use getfullargspec in PY3, allowing annotations in subscribers
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--pyramid/config/util.py8
-rw-r--r--pyramid/tests/test_config/test_util.py7
3 files changed, 16 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index e4132cda5..adf2224a5 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -238,3 +238,5 @@ Contributors
- Hugo Branquinho, 2014/11/25
- Adrian Teng, 2014/12/17
+
+- Ilja Everila, 2015/02/05
diff --git a/pyramid/config/util.py b/pyramid/config/util.py
index 892592196..b91f3f7ab 100644
--- a/pyramid/config/util.py
+++ b/pyramid/config/util.py
@@ -22,6 +22,12 @@ ActionInfo = ActionInfo # support bw compat imports
MAX_ORDER = 1 << 30
DEFAULT_PHASH = md5().hexdigest()
+# support annotations and keyword-only arguments in PY3
+try:
+ getargspec = inspect.getfullargspec
+except AttributeError:
+ getargspec = inspect.getargspec
+
def as_sorted_tuple(val):
if not is_nonstr_iter(val):
val = (val,)
@@ -201,7 +207,7 @@ def takes_one_arg(callee, attr=None, argname=None):
return False
try:
- argspec = inspect.getargspec(fn)
+ argspec = getargspec(fn)
except TypeError:
return False
diff --git a/pyramid/tests/test_config/test_util.py b/pyramid/tests/test_config/test_util.py
index bb61714ae..ccf7fa260 100644
--- a/pyramid/tests/test_config/test_util.py
+++ b/pyramid/tests/test_config/test_util.py
@@ -568,6 +568,13 @@ class Test_takes_one_arg(unittest.TestCase):
foo = Foo()
self.assertTrue(self._callFUT(foo.method))
+ def test_function_annotations(self):
+ def foo(bar):
+ """ """
+ # avoid SyntaxErrors in python2, this if effectively nop
+ getattr(foo, '__annotations__', {}).update({'bar': 'baz'})
+ self.assertTrue(self._callFUT(foo))
+
class TestNotted(unittest.TestCase):
def _makeOne(self, predicate):
from pyramid.config.util import Notted