[ python-Bugs-966623 ] execfile -> type() created objects w/ no __module__ error

SourceForge.net noreply at sourceforge.net
Fri Jun 11 11:13:04 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: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Anthony Baxter (anthonybaxter)
>Assigned to: Anthony Baxter (anthonybaxter)
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-12 01:13

Message:
Logged In: YES 
user_id=29957

Fix checked in, will be in 2.4a1 and 2.3.5.
Objects/typeobject 2.259, 2.241.6.10
Misc/NEWS 1.999,  1.831.4.120



----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-06-12 00:03

Message:
Logged In: YES 
user_id=6656

I don't think there's an answer to that.

OTOH, I think it's more important that this gets fixed than that it 
gets fixed 100% perfectly.  IOW, do what you like, but please do 
something :-)

----------------------------------------------------------------------

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