[Python-bugs-list] [ python-Bugs-765228 ] Subclassing from Modules
SourceForge.net
noreply@sourceforge.net
Thu, 03 Jul 2003 03:32:45 -0700
Bugs item #765228, was opened at 2003-07-03 12:32
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=765228&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: M.-A. Lemburg (lemburg)
Assigned to: Nobody/Anonymous (nobody)
Summary: Subclassing from Modules
Initial Comment:
In Python 2.2.3 there's a problem with accidental
subclassing from a Python module, e.g.
import MyStuff
class A(MyStuff):
pass
this gives no error until you try to instantiate the
class:
o = A()
TypeError: 'module' object is not callable
In Python 2.3 the error is generated at module
startup time:
class A(MyStuff):
pass
TypeError: function takes at most 2 arguments (3 given)
Since it is rather common that you create modules which
have the same name as their most important class, I
would find it more appropriate to raise a TypeError
with a message "can't subclass a module instance"
in both versions.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=765228&group_id=5470