[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: I am closing this for now. We can re-open it later if problems will appear in 3.7. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: New changeset 5d8bb5d07be2a9205e7059090f0ac5360d36b217 by Ivan Levkivskyi (Miss Islington (bot)) in branch '3.7': bpo-32999: Revert GH-6002 (fc7df0e6) (GH-6189) (GH-6190) https://github.com/python/cpython/commit/5d8bb5d07be2a9205e7059090f0ac5360d36b217

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread miss-islington
Change by miss-islington : -- pull_requests: +5936 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread INADA Naoki
INADA Naoki added the comment: New changeset f757b72b2524ce3451d2269f0b8a9f0593a7b27f by INADA Naoki in branch 'master': bpo-32999: Revert GH-6002 (fc7df0e6) (GH-6189) https://github.com/python/cpython/commit/f757b72b2524ce3451d2269f0b8a9f0593a7b27f -- __

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread INADA Naoki
Change by INADA Naoki : -- pull_requests: +5934 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread miss-islington
miss-islington added the comment: New changeset 346964ba0586e402610ea886e70bee1294874781 by Miss Islington (bot) in branch '3.7': bpo-33018: Improve issubclass() error checking and message. (GH-5944) https://github.com/python/cpython/commit/346964ba0586e402610ea886e70bee1294874781 --

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread miss-islington
Change by miss-islington : -- keywords: +patch pull_requests: +5932 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-li

[issue33018] Improve issubclass() error checking and message

2018-03-22 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: New changeset 40472dd42de4f7265d456458cd13ad6894d736db by Ivan Levkivskyi (jab) in branch 'master': bpo-33018: Improve issubclass() error checking and message. (GH-5944) https://github.com/python/cpython/commit/40472dd42de4f7265d456458cd13ad6894d736db -

[issue33018] Improve issubclass() error checking and message

2018-03-21 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: > Would you merge this into master? OK, I played with this a bit and it looks good. There is however a merge conflict now, and a NEWS item is missing. I will leave a comment in the PR. -- ___ Python tracker

[issue33018] Improve issubclass() error checking and message

2018-03-21 Thread Guido van Rossum
Guido van Rossum added the comment: OTOH if we don't do this now, it's not going to be any easier to make this change in 3.8. Maybe now's the time to experiment with it, and we can drop it in rc1 if it causes problems. @Ivan, your thoughts? Would you merge this into master? --

[issue33018] Improve issubclass() error checking and message

2018-03-20 Thread Guido van Rossum
Guido van Rossum added the comment: Hmm... That is actually a not entirely imaginary risk, right? Can you come up with a test program that would fail that way? -- ___ Python tracker __

[issue33018] Improve issubclass() error checking and message

2018-03-20 Thread INADA Naoki
INADA Naoki added the comment: If there are some code which depend on ABC.__subclasscheck__() allow class-like object, we'll have to revert it in 3.7b4 or rc. I think it's the only risk. -- ___ Python tracker __

[issue33018] Improve issubclass() error checking and message

2018-03-20 Thread Guido van Rossum
Guido van Rossum added the comment: While we're in feature freeze mode, we're not in release candidate mode yet. I presume the code that would be patched in 3.7 is no different from master? What's the concern? It doesn't seem anyone thinks it's risky? -- ___

[issue33018] Improve issubclass() error checking and message

2018-03-20 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: I am still -1 on changing this in Python 3.7, unless Guido wants this in 3.7, if yes, then we can go ahead. Otherwise, I think we can consider just merging this into master, in this case I would switch to the PR to discuss the details. -- nosy: +gvan

[issue33018] Improve issubclass() error checking and message

2018-03-12 Thread Joshua Bronson
Joshua Bronson added the comment: I'll share the use case that prompted me to submit this PR in the first place. I am the author of bidict (https://pypi.python.org/pypi/bidict), which provides a bidirectional dict class. A bidict is just like a dict, except it automatically maintains its inve

[issue33018] Improve issubclass() error checking and message

2018-03-10 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: I agree except that I'd like to see it in 3.7 too. -- ___ Python tracker ___ ___ Python-bugs-list

[issue33018] Improve issubclass() error checking and message

2018-03-10 Thread INADA Naoki
INADA Naoki added the comment: My current opinion is: * -1 for 3.6: Behavior should not be changed without strong reason, even the behavior is not documented. * +1 for 3.8: I like strict and less magic. * +0 for 3.7: beta3 is bit late, but this change has very little chance to cause real w

[issue33018] Improve issubclass() error checking and message

2018-03-09 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: Regarding status quo (expanding the examples of @inada.naoki and @jab): >>> import typing >>> import collections.abc as cabc >>> issubclass(typing.Mapping, cabc.Mapping) Traceback (most recent call last): File "", line 1, in File "/home/izbyshev/workspace

[issue33018] Improve issubclass() error checking and message

2018-03-09 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: To be honest I am still undecided on this. In principle, I am OK with status quo, but I am also OK, with the PR that will prohibit non-classes. I am a bit worried that it may break some existing code, so it is probably not for 3.7. -- __

[issue33018] Improve issubclass() error checking and message

2018-03-09 Thread INADA Naoki
INADA Naoki added the comment: >> Isn't it just a limitation? >> Most Python-implemented objects supports weakref. I don't think "requiring >> weakref support implies it must be type object". > Formally, there is no implication. It is the abc module authors who know the > truth. But I can't i

[issue33018] Improve issubclass() error checking and message

2018-03-08 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: PR 5944 changes ABC.__subclasscheck__ (not issubclass) to check its first argument, so if it's merged there will be no crash even with the revert. -- ___ Python tracker ___

[issue33018] Improve issubclass() error checking and message

2018-03-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Can > https://github.com/python/cpython/commit/fc7df0e664198cb05cafd972f190a18ca422989c > be reverted? Even if subclass() will check explicitly that its first argument is a type, ABC.__subclasscheck__() can be called directly, and it shouldn't crash when

[issue33018] Improve issubclass() error checking and message

2018-03-08 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: > Isn't it just a limitation? > Most Python-implemented objects supports weakref. I don't think "requiring > weakref support implies it must be type object". Formally, there is no implication. It is the abc module authors who know the truth. But I can't imag

[issue33018] Improve issubclass() error checking and message

2018-03-08 Thread INADA Naoki
INADA Naoki added the comment: > 1. ABCMeta.register() accepts types only. Yes. While ABC.register() and issubclass() have different users (e.g. ABC.register() will be used by framework author, and issubclass will be used by framework users), it's positive reason to remove non-type support.

[issue33018] Improve issubclass() error checking and message

2018-03-08 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: I do not see any point in allowing non-types in ABCMeta.__subclasscheck__. Currently, ABCs are clearly not designed to support non-types: 1. ABCMeta.register() accepts types only. 2. ABCMeta.__subclasscheck__ implicitly requires its arguments to support weak

[issue33018] Improve issubclass() error checking and message

2018-03-07 Thread INADA Naoki
INADA Naoki added the comment: Hmm, normal class doesn't support issubclass(class-like. class). ``` Python 3.8.0a0 (heads/master:fc7df0e664, Mar 8 2018, 09:00:43) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import typing >>> issubclass(typing

[issue33018] Improve issubclass() error checking and message

2018-03-07 Thread INADA Naoki
INADA Naoki added the comment: issubclass(class-like, class-like) is allowed. I don't think raising type error for issubclass(class-like, ABC) is good idea. It should return False. -- ___ Python tracker ___

[issue33018] Improve issubclass() error checking and message

2018-03-07 Thread INADA Naoki
INADA Naoki added the comment: https://bugs.python.org/msg313396 -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue33018] Improve issubclass() error checking and message

2018-03-07 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: ABC.register() has an explicit check, and it is mentioned in PEP 3119. The point here is not to change issubclass(), but to change ABC.__subclasscheck__(). It may conceivably have stricter requirements than issubclass() has. But certainly an advice from actu

[issue33018] Improve issubclass() error checking and message

2018-03-07 Thread INADA Naoki
INADA Naoki added the comment: Why `issubclass()` doesn't check it? Maybe, non-type class is supported by Python. But I'm not sure. I'm not meta programming expert. But we use "duck typing". In this case, if the object (a) supports weakref and (2) has __mro__ and it is tuple, we treat the

[issue33018] Improve issubclass() error checking and message

2018-03-06 Thread Joshua Bronson
New submission from Joshua Bronson : Creating this issue by request of INADA Naoki to discuss my proposed patch in https://github.com/python/cpython/pull/5944. Copy/pasting from that PR: If you try something like issubclass('not a class', str), you get a helpful error message that immediately