Author: Mark Young <marky1...@gmail.com>
Branch: py3k
Changeset: r84462:d9251d36a77d
Date: 2016-05-14 01:47 -0400
http://bitbucket.org/pypy/pypy/changeset/d9251d36a77d/

Log:    Fix test_inspect.

diff --git a/lib-python/3/inspect.py b/lib-python/3/inspect.py
--- a/lib-python/3/inspect.py
+++ b/lib-python/3/inspect.py
@@ -1341,7 +1341,8 @@
     except AttributeError:
         return
     else:
-        if not isinstance(meth, _NonUserDefinedCallables):
+        if  (meth is not getattr(type, method_name) and
+             meth is not getattr(object, method_name)):
             # Once '__signature__' will be added to 'C'-level
             # callables, this check won't be necessary
             return meth
diff --git a/lib-python/3/test/test_inspect.py 
b/lib-python/3/test/test_inspect.py
--- a/lib-python/3/test/test_inspect.py
+++ b/lib-python/3/test/test_inspect.py
@@ -851,15 +851,7 @@
         else:
             self.fail('Exception not raised')
         self.assertIs(type(ex1), type(ex2))
-        try:
-            self.assertEqual(str(ex1), str(ex2))
-        except AssertionError:
-            # XXX: PyPy 3.2 produces slightly different error messages,
-            # to be fixed in 3.3
-            assert (str(ex1).startswith('<lambda>() takes ') and
-                    'non-keyword' in str(ex1) or
-                    any(name in str(ex2)
-                        for name in ('positional', 'keyword-only')))
+        self.assertEqual(str(ex1), str(ex2))
         del ex1, ex2
 
     def makeCallable(self, signature):
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -256,7 +256,7 @@
     RegrTest('test_importhooks.py', core=True),
     RegrTest('test_importlib', 'XXX is a directory'),
     RegrTest('test_index.py'),
-    RegrTest('test_inspect.py'),
+    RegrTest('test_inspect.py', usemodules="struct unicodedata"),
     RegrTest('test_int.py', core=True),
     RegrTest('test_int_literal.py', core=True),
     RegrTest('test_io.py', core=True, usemodules='array binascii'),
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -384,6 +384,7 @@
         return self
 
 class defaultdict(dict):
+    __slots__ = ["default_factory"]
     
     def __init__(self, *args, **kwds):
         if len(args) > 0:
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -167,6 +167,7 @@
         # that the length of the defaults_w does not vary too much.
         co_argcount = signature.num_argnames() # expected formal arguments, 
without */**
         co_kwonlyargcount = signature.num_kwonlyargnames()
+        too_many_args = False
 
         # put the special w_firstarg into the scope, if it exists
         if w_firstarg is not None:
@@ -197,6 +198,7 @@
             input_argcount += take
 
         # collect extra positional arguments into the *vararg
+        kwonly_given = 0
         if signature.has_vararg():
             args_left = co_argcount - upfront
             if args_left < 0:  # check required by rpython
@@ -210,13 +212,10 @@
             loc = co_argcount + co_kwonlyargcount
             scope_w[loc] = self.space.newtuple(starargs_w)
         elif avail > co_argcount:
-            kwonly_given = 0
             for i in range(co_argcount, co_argcount + co_kwonlyargcount):
                 if scope_w[i] is None:
                     kwonly_given += 1
-            raise ArgErrTooMany(signature.num_argnames(),
-                                0 if defaults_w is None else len(defaults_w),
-                                avail, kwonly_given)
+            too_many_args = True
 
         # if a **kwargs argument is needed, create the dict
         w_kwds = None
@@ -251,6 +250,10 @@
                 else:
                     raise ArgErrUnknownKwds(self.space, num_remainingkwds, 
keywords,
                                             kwds_mapping, self.keyword_names_w)
+        if too_many_args:
+            raise ArgErrTooMany(signature.num_argnames(),
+                                0 if defaults_w is None else len(defaults_w),
+                                avail, kwonly_given)
 
         # check for missing arguments and fill them from the kwds,
         # or with defaults, if available
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to