This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: new.instance() breaks with new classes
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: anthonybaxter, gvanrossum
Priority: normal Keywords:

Created on 2002-03-26 12:49 by anthonybaxter, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (2)
msg9989 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-03-26 12:49
>>> class a1: pass
... 
>>> a2 = type('a2', (), {})
>>> class a3(object): pass
... 
>>> a1
<class __main__.a1 at 0x815111c>
>>> a2
<class '__main__.a2'>
>>> a3
<class '__main__.a3'>
>>> import new
>>> new.instance(a1)
<__main__.a1 instance at 0x8148a04>
>>> new.instance(a2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: instance() argument 1 must be class, not type
>>> new.instance(a3)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: instance() argument 1 must be class, not type

2.2 branch and current CVS...  _so_ not a 2.2 bugfix
necessity, tho :)
msg9990 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-04-04 17:08
Logged In: YES 
user_id=6380

There's no need to use new.instance() for new-style classes.

You should be able to do this using the __new__ method of
the new-style class.
History
Date User Action Args
2022-04-10 16:05:09adminsetgithub: 36331
2002-03-26 12:49:35anthonybaxtercreate