[ python-Bugs-1183959 ] return val in __init__ doesn't raise
TypeError in new-style
SourceForge.net
noreply at sourceforge.net
Fri Apr 15 21:20:07 CEST 2005
Bugs item #1183959, was opened at 2005-04-15 22:16
Message generated for change (Comment added) made by adalx
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1183959&group_id=5470
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Adal Chiriliuc (adalx)
Assigned to: Nobody/Anonymous (nobody)
Summary: return val in __init__ doesn't raise TypeError in new-style
Initial Comment:
returning a value (other than None) from __init__ is
supposed to raise TypeError. This only works for
old-style classes.
----------------------------------------------------------------------
>Comment By: Adal Chiriliuc (adalx)
Date: 2005-04-15 22:20
Message:
Logged In: YES
user_id=1067739
# I've failed to attach this file so I've added a comment.
This should be modified to report eventual failure and added
to the test library.
class LegalConstructor1(object):
def __init__(self):
return
class LegalConstructor2(object):
def __init__(self):
return None
class IlegalConstructor(object):
def __init__(self):
return "x"
class LegalConstructorOld1:
def __init__(self):
return
class LegalConstructorOld2:
def __init__(self):
return None
class IlegalConstructorOld:
def __init__(self):
return "x"
a = LegalConstructor1()
print a
b = LegalConstructor2()
print b
x = LegalConstructorOld1()
print a
y = LegalConstructorOld2()
print b
# !!! This should raise TypeError
c = IlegalConstructor()
print c
z = IlegalConstructorOld()
print z
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1183959&group_id=5470
More information about the Python-bugs-list
mailing list