[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-08-19 Thread Berker Peksag
Berker Peksag added the comment: Thanks! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-08-19 Thread Roundup Robot
Roundup Robot added the comment: New changeset c3498187f998 by Berker Peksag in branch 'default': Issue #27157: Make only type() itself accept the one-argument form https://hg.python.org/cpython/rev/c3498187f998 -- nosy: +python-dev ___ Python

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-08-14 Thread Emanuel Barry
Emanuel Barry added the comment: Rebased patch so that it applies cleanly again. -- Added file: http://bugs.python.org/file44109/type_one_argument_5.patch ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-07-13 Thread ppperry
ppperry added the comment: Ping -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Emanuel Barry added the comment: New patch with Berker's comments. I'm really not used to Sphinx markup so thanks for that! > Is there any person who really thinks that their own patch is *not* ready for > commit review? :) Partial patches aren't that uncommon in some projects. I also

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the patch, Emanuel. I left some comments about Sphinx markup on Rietveld. > Berker, I don't mind if people mark their own patches for commit review *when > they think it is ready for commit*. Is there any person who really thinks that their own

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread R. David Murray
R. David Murray added the comment: Berker, I don't mind if people mark their own patches for commit review *when they think it is ready for commit*. (Just as with reviewers, if they start being consistently right, they are ready for commit privs :) However, a non-committer setting a patch

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Berker Peksag
Berker Peksag added the comment: Please don't mark your own patch as 'commit review'. -- nosy: +berker.peksag stage: commit review -> patch review ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Changes by Emanuel Barry : Added file: http://bugs.python.org/file43060/type_one_argument_3.patch ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Emanuel Barry added the comment: New patch with tests and documentation. I didn't really know where to put the tests; test_types seemed reasonable to me (other option was test_metaclass). -- stage: test needed -> commit review ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Changes by Emanuel Barry : -- Removed message: http://bugs.python.org/msg266711 ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Eryk Sun
Changes by Eryk Sun : -- Removed message: http://bugs.python.org/msg266710 ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Emanuel Barry added the comment: Let me just make sure I got you right - you're fine with `type` and only `type` being able to use the one-argument form in 3.6, but prefer 3.5 and 2.7 to be even more permissive than they currently are? Regardless, I don't think this should go into a bugfix

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Eryk Sun
Eryk Sun added the comment: > Please treat this as a new feature (just in case) and only > apply it to 3.6. How about changing PyType_CheckExact to PyType_Check for 2.7 and 3.5? It solves the original problem by expanding the single-argument case to metaclasses that aren't an exact instance

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Needed tests and updating the documentation. -- nosy: +serhiy.storchaka stage: commit review -> test needed ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Guido van Rossum
Guido van Rossum added the comment: No, just an entry in Misc/NEWS. --Guido (mobile) -- ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Emanuel Barry added the comment: Fair enough. Should this get a note in What's new? Possibly in the "Changes in Python API" section. -- stage: patch review -> commit review versions: +Python 3.6 -Python 2.7, Python 3.4 ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Guido van Rossum
Guido van Rossum added the comment: OK, the patch looks fine. Please treat this as a new feature (just in case) and only apply it to 3.6. -- ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Emanuel Barry
Emanuel Barry added the comment: Yes, `metatype == _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

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Eryk Sun
Eryk Sun added the comment: > why write `metatype == _Type` rather than > PyType_CheckExact(metatype)`? If only `type` should implement this special case, then it needs to be `metatype == _Type`. This was actually how it was implemented in 2.2a3:

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Guido van Rossum
Guido van Rossum added the comment: I don't recall writing that any more, but that fix looks right. (Though why write `metatype == _Type` rather than `PyType_CheckExact(metatype)`?) -- ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: Guido, this is your code. Do you care to opine? -- nosy: +gvanrossum, rhettinger ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Emanuel Barry
Changes by Emanuel Barry : -- stage: needs patch -> patch review ___ Python tracker ___

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Emanuel Barry
Emanuel Barry added the comment: +1. I prefer that change, as using subclasses of `type` as if they were type itself never made sense to me. This shouldn't break existing code, but if it does, it was either a concealed bug or a very bad idea to begin with, and should be fixed either way.

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Eryk Sun
Eryk Sun added the comment: All types are instances of `type`, so the single argument case makes sense to me as a 'constructor'. It always returns an instance of `type`, just not a new instance. >>> X = type('X', (type,), {}) >>> type(X) >>> isinstance(type(X), type)

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Mon, May 30, 2016 at 01:43:22AM +, ppperry wrote: > steven.daprano, you don't appear to have properly read the issue > comments. Ack; I saw your comment about the metaclass, then saw your retraction of the metaclass issue, then misinterpreted your

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread R. David Murray
R. David Murray added the comment: When I hit this recently I assumed that that error message meant I'd screwed up the metaclass definition. But if there's a way to improve the error message that would be great. I'll add this to the list of bugs I'm making for the sprints, perhaps one of

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread ppperry
ppperry added the comment: steven.daprano, you don't appear to have properly read the issue comments. I originally underspecified the conditions necessary to reproduce this, producing Emanuel Barry's closure. I then added a proper reproducer in the third comment, which does work in the

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: I am unable to replicate this in Python 2.7, 3.3 or 3.6. I haven't bothered to test against other versions, because I think that this is a PyShell issue, not a Python issue. (I think you are using PyShell, based on the traceback given.) Before reporting bugs

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Emanuel Barry
Emanuel Barry added the comment: Yes, that would be preferable. The error message is at Objects/typeobject.c#l2301, but keep in mind that this message is shown for both faulty calls to type() as well as any of its subclasses that don't override __new__, and I'm lukewarm on adding e.g. a

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread ppperry
ppperry added the comment: Ignore the first part of my previous comment; I improperly tested that. -- title: Unhelpful error message when one calls an instance of a subclass of type -> Unhelpful error message when one calls a subclass of type with a custom metaclass

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Emanuel Barry
Emanuel Barry added the comment: In Objects/typeobject.c#L2290, the code checks that the (meta?)class is exactly `type` and that there's one argument, then returns `Py_TYPE(x)`. Subclasses of `type` allowing a single argument is a side-effect of not overriding __new__, not a documented

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread ppperry
ppperry added the comment: Also happens on 2.7, although you have to declare the metaclass using `__metaclass__ = meta` instead. -- versions: +Python 2.7 ___ Python tracker

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread ppperry
ppperry added the comment: This issue only happens when the type in question has a custom metaclass: >>> class meta(type):pass >>> class X(type,metaclass=meta):pass >>> X(X) [Same unhelpful TypeError] -- resolution: works for me -> status: closed -> open title: Unhelpful error message