[ python-Bugs-1155938 ] yield in __init__ causes broken new-style class

SourceForge.net noreply at sourceforge.net
Thu Mar 3 17:02:16 CET 2005


Bugs item #1155938, was opened at 2005-03-03 15:42
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1155938&group_id=5470

Category: Type/class unification
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Steve Alexander (stevea_zope)
Assigned to: Nobody/Anonymous (nobody)
Summary: yield in __init__ causes broken new-style class

Initial Comment:

 class Foo(object):
 
     def __init__(self):
         print "foo"
         raise RuntimeError
         yield 23

 Foo()

With a classic class, this correctly fails saying
"__init__ must return None".  With a new-style class,
the class suite works, and Foo() is called without
reporting an error, but also without printing "foo".


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

>Comment By: Michael Hudson (mwh)
Date: 2005-03-03 16:02

Message:
Logged In: YES 
user_id=6656

You don't have to be that cute:

>>> class Foo(object):
...  def __init__(self):
...   return "foo"
... 

where did that check go?

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1155938&group_id=5470


More information about the Python-bugs-list mailing list