[ python-Bugs-966623 ] execfile -> type() created objects w/ no
__module__ error
SourceForge.net
noreply at sourceforge.net
Fri Jun 4 12:49:47 EDT 2004
Bugs item #966623, was opened at 2004-06-05 01:46
Message generated for change (Comment added) made by anthonybaxter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=966623&group_id=5470
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Anthony Baxter (anthonybaxter)
Assigned to: Nobody/Anonymous (nobody)
Summary: execfile -> type() created objects w/ no __module__ error
Initial Comment:
Apologies for the imprecise summary - I have no idea
where the problem is here.
Thanks to JP Calderone for this little horror.
(distilled down from his example)
bonanza% cat foo.py
print type('F', (object,), {})().__class__.__module__
bonanza% python2.3 -c "execfile('foo.py', {})"
Traceback (most recent call last):
File "<string>", line 1, in ?
File "foo.py", line 1, in ?
print type('F', (object,), {})().__class__.__module__
SystemError: error return without exception set
bonanza% python2.4 -c "execfile('foo.py', {})"
Traceback (most recent call last):
File "<string>", line 1, in ?
File "foo.py", line 1, in ?
print type('F', (object,), {})().__class__.__module__
SystemError: error return without exception set
----------------------------------------------------------------------
>Comment By: Anthony Baxter (anthonybaxter)
Date: 2004-06-05 02:49
Message:
Logged In: YES
user_id=29957
Is it better to fix this here, or in the type() call to make
sure there's always a __module__ ?
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2004-06-05 02:36
Message:
Logged In: YES
user_id=6656
Ah, I was about to attach the same test :-)
Do add a test and use PEP 7 code if you check it in...
----------------------------------------------------------------------
Comment By: Anthony Baxter (anthonybaxter)
Date: 2004-06-05 02:27
Message:
Logged In: YES
user_id=29957
The attached patch fixes this to raise an AttributeError if
the object has no __module__. The other approach to fixing
it would be to make sure that the object created always gets
a __module__, but I have no idea in that case what a
reasonable fix would be.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=966623&group_id=5470
More information about the Python-bugs-list
mailing list