[pypy-commit] pypy default: Forgot this version of the file. Thanks amaury.

arigo noreply at buildbot.pypy.org
Mon Dec 5 20:40:12 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r50181:0732486f6a76
Date: 2011-12-05 20:39 +0100
http://bitbucket.org/pypy/pypy/changeset/0732486f6a76/

Log:	Forgot this version of the file. Thanks amaury.

diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -379,12 +379,14 @@
 class defaultdict(dict):
     
     def __init__(self, *args, **kwds):
-        self.default_factory = None
-        if 'default_factory' in kwds:
-            self.default_factory = kwds.pop('default_factory')
-        elif len(args) > 0 and (callable(args[0]) or args[0] is None):
-            self.default_factory = args[0]
+        if len(args) > 0:
+            default_factory = args[0]
             args = args[1:]
+            if not callable(default_factory) and default_factory is not None:
+                raise TypeError("first argument must be callable")
+        else:
+            default_factory = None
+        self.default_factory = default_factory
         super(defaultdict, self).__init__(*args, **kwds)
  
     def __missing__(self, key):


More information about the pypy-commit mailing list