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.

Author abarry
Recipients abarry, eryksun, gvanrossum, ppperry, r.david.murray, rhettinger, steven.daprano
Date 2016-05-30.13:37:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464615459.94.0.982101885423.issue27157@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, `metatype == &PyType_Type` makes sure that only `type` itself is valid for the one-argument part, whereas subclasses can also do so right now. I clarified that in a comment in the new patch, so that someone doesn't accidentally revert this, thinking PyType_CheckExact is fine.

Before the patch:

>>> type(1, 2, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type() argument 1 must be str, not int

After the patch:

>>> type(1, 2, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type.__new__() argument 1 must be str, not int
>>> class X(type): pass
...
>>> X(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type.__new__() argument 1 must be str, not int
History
Date User Action Args
2016-05-30 13:37:39abarrysetrecipients: + abarry, gvanrossum, rhettinger, steven.daprano, r.david.murray, eryksun, ppperry
2016-05-30 13:37:39abarrysetmessageid: <1464615459.94.0.982101885423.issue27157@psf.upfronthosting.co.za>
2016-05-30 13:37:39abarrylinkissue27157 messages
2016-05-30 13:37:39abarrycreate