[Python-checkins] cpython: inspect.Signature.bind: Add **kwargs/positional-only check back

yury.selivanov python-checkins at python.org
Wed Jan 29 02:54:42 CET 2014


http://hg.python.org/cpython/rev/ec6bd526b70a
changeset:   88800:ec6bd526b70a
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Tue Jan 28 20:54:28 2014 -0500
summary:
  inspect.Signature.bind: Add **kwargs/positional-only check back

files:
  Lib/inspect.py |  8 ++++++++
  1 files changed, 8 insertions(+), 0 deletions(-)


diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -2323,6 +2323,14 @@
                                     format(arg=param_name)) from None
 
             else:
+                if param.kind == _POSITIONAL_ONLY:
+                    # This should never happen in case of a properly built
+                    # Signature object (but let's have this check here
+                    # to ensure correct behaviour just in case)
+                    raise TypeError('{arg!r} parameter is positional only, '
+                                    'but was passed as a keyword'. \
+                                    format(arg=param.name))
+
                 arguments[param_name] = arg_val
 
         if kwargs:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list