summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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