[Python-3000-checkins] r55910 - python/branches/p3yk/Lib/abc.py
guido.van.rossum
python-3000-checkins at python.org
Mon Jun 11 22:05:21 CEST 2007
Author: guido.van.rossum
Date: Mon Jun 11 22:05:17 2007
New Revision: 55910
Modified:
python/branches/p3yk/Lib/abc.py
Log:
_Abstract.__new__ now requires either no arguments or __init__ overridden.
Modified: python/branches/p3yk/Lib/abc.py
==============================================================================
--- python/branches/p3yk/Lib/abc.py (original)
+++ python/branches/p3yk/Lib/abc.py Mon Jun 11 22:05:17 2007
@@ -29,15 +29,20 @@
"""Helper class inserted into the bases by ABCMeta (using _fix_bases()).
You should never need to explicitly subclass this class.
+
+ There should never be a base class between _Abstract and object.
"""
def __new__(cls, *args, **kwds):
am = cls.__dict__.get("__abstractmethods__")
if am:
- raise TypeError("can't instantiate abstract class %s "
+ raise TypeError("Can't instantiate abstract class %s "
"with abstract methods %s" %
(cls.__name__, ", ".join(sorted(am))))
- return super(_Abstract, cls).__new__(cls, *args, **kwds)
+ if (args or kwds) and cls.__init__ is object.__init__:
+ raise TypeError("Can't pass arguments to __new__ "
+ "without overriding __init__")
+ return object.__new__(cls)
@classmethod
def __subclasshook__(cls, subclass):
More information about the Python-3000-checkins
mailing list