Message266693
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 |
|
Date |
User |
Action |
Args |
2016-05-30 13:37:39 | abarry | set | recipients:
+ abarry, gvanrossum, rhettinger, steven.daprano, r.david.murray, eryksun, ppperry |
2016-05-30 13:37:39 | abarry | set | messageid: <1464615459.94.0.982101885423.issue27157@psf.upfronthosting.co.za> |
2016-05-30 13:37:39 | abarry | link | issue27157 messages |
2016-05-30 13:37:39 | abarry | create | |
|