[issue25958] Implicit ABCs have no means of "anti-registration"

2017-06-09 Thread Mariatta Wijaya
Changes by Mariatta Wijaya : -- pull_requests: -2123 ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2017-06-09 Thread Mariatta Wijaya
Mariatta Wijaya added the comment: New changeset 753422f6e32e13d96319b090788f0474f1e21fc4 by Mariatta in branch '3.6': bpo-30266: support "= None" pattern in AbstractContextManager (GH-1448) (GH-2054) https://github.com/python/cpython/commit/753422f6e32e13d96319b090788f0474f1e21fc4

[issue25958] Implicit ABCs have no means of "anti-registration"

2017-06-09 Thread Mariatta Wijaya
Changes by Mariatta Wijaya : -- pull_requests: +2123 ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2017-06-09 Thread Mariatta Wijaya
Changes by Mariatta Wijaya : -- pull_requests: -2115 ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2017-06-09 Thread Mariatta Wijaya
Changes by Mariatta Wijaya : -- pull_requests: +2115 ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2017-06-09 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset 57161aac5eb9bcb0b43e551a1937ff0a84c1ec52 by Guido van Rossum (Jelle Zijlstra) in branch 'master': bpo-30266: support "= None" pattern in AbstractContextManager (#1448)

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Guido van Rossum
Changes by Guido van Rossum : -- stage: commit review -> resolved status: open -> closed ___ Python tracker ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: On my machine 8 tests are always skipped: test_devpoll test_kqueue test_msilib test_ossaudiodev test_startfile test_winreg test_winsound test_zipfile64 All others tests pass OK. The main part of the work is by Andrew Barnert, I only introduced small

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Guido van Rossum
Guido van Rossum added the comment: Pushed, let's see what the buildbots say. -- resolution: -> fixed stage: patch review -> commit review ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset 72b9f195569c by Guido van Rossum in branch 'default': Anti-registration of various ABC methods. https://hg.python.org/cpython/rev/72b9f195569c -- nosy: +python-dev ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Guido van Rossum
Guido van Rossum added the comment: The patch LGTM. Do all the tests pass? Who should be attributed in the commit message and the Misc/NEWS item? -- ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-15 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: Oops, sorry, forgot one import, all tests pass with the corrected patch. -- Added file: http://bugs.python.org/file44123/abarnert_rebased2.diff ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-15 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: I have manually "rebased" the patch taking into account that part of the work has been done in http://bugs.python.org/issue25987 Serhiy, Martin could you please review the latest patch and check that everything is OK? Andrew did a really good job and I

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-07-14 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: What holds back this issue now? It looks like Andrew did a great job. When I was making a patch for #25987 following Andrew's ideas, I was surprised how many different idioms has been used for __subclasshook__. I was going to open an issue on this, when I

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-06-30 Thread Ivan Levkivskyi
Changes by Ivan Levkivskyi : -- nosy: +levkivskyi ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-06-07 Thread Ethan Furman
Changes by Ethan Furman : -- nosy: +ethan.furman ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Andrew Barnert
Andrew Barnert added the comment: > I did actually mean a version changed notice for the data model change. I see > this as a small expansion of the Python object API. Previously, > __reversed__() had to be a function, now you are also allowed to set it to > None. The collections ABCs are

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Martin Panter
Martin Panter added the comment: This is not really my area of expertise, but I would have thought if you defined a __special__ method to something illegal (non-callable, or wrong signature) it would be reasonable for Python to raise an error at class definition (or assignment) time, not just

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Martin Panter
Martin Panter added the comment: The documentation about double-underscore names: . It says any undocumented usage may be broken. The technique with __hash__() is already documented:

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Guido van Rossum
Guido van Rossum added the comment: > This is not really my area of expertise, but I would have thought if you > defined a __special__ method to something illegal (non-callable, or wrong > signature) it would be reasonable for Python to raise an error at class > definition (or assignment)

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-02-01 Thread Andrew Barnert
Andrew Barnert added the comment: > This is not really my area of expertise, but I would have thought if you > defined a __special__ method to something illegal (non-callable, or wrong > signature) it would be reasonable for Python to raise an error at class > definition (or assignment) time,

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-18 Thread Andrew Barnert
Andrew Barnert added the comment: Style changes based on Martin's review -- Added file: http://bugs.python.org/file41650/patch5.diff ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-18 Thread Andrew Barnert
Changes by Andrew Barnert : Removed file: http://bugs.python.org/file41650/patch5.diff ___ Python tracker ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-08 Thread Martin Panter
Martin Panter added the comment: I don’t have strong opinions about the Reversible class because I don’t imagine needing it. My instinct was __reverse__() is independent of __iter__(), so it should not be a subclass. But I don’t really mind either way. I did actually mean a version changed

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-07 Thread Andrew Barnert
Changes by Andrew Barnert : Added file: http://bugs.python.org/file41527/patch4a.diff ___ Python tracker ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-06 Thread R. David Murray
Changes by R. David Murray : -- nosy: -r.david.murray ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-06 Thread Guido van Rossum
Guido van Rossum added the comment: Uploading a flattened version of patch3.diff. -- Added file: http://bugs.python.org/file41519/patch3-regenerated.diff ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-06 Thread Guido van Rossum
Guido van Rossum added the comment: FWIW, it looks fine to me -- but I'm hoping to get Serhiy's agreement first. Serhiy: feel free to commit when you're happy. -- ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Added few stylistic nitpicks and asked few questions on Rietveld. -- ___ Python tracker ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Guido van Rossum
Guido van Rossum added the comment: I'm regenerating the patch in the hope that it will trigger the code review hook. -- Added file: http://bugs.python.org/file41508/abarnert-patch-regenerated.diff ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that setting some special methods (such as __copy__, __deepcopy__, __reduce_ex__, __reduce__, __setstate__, etc) to None has different meaning. The value None is just ignored and corresponding operation is fall back to other methods. For example

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Andrew Barnert
Andrew Barnert added the comment: The second patch takes into account all the issues raised by Martin and Guido, as well as some other changes that didn't make it into the first patch because Windows hates me. And it should be flattened into a single commit, and therefore should hopefully

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: There is already a precedent for None, but it would have been nicer to use NotImplemented. -- nosy: +rhettinger ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Needed tests for Hashable, Awaitable, Coroutine, AsyncIterable, AsyncIterator, Iterator, Generator, Sized, Container, Callable. The patch adds some tests for __iadd__ and __eq__. I think needed tests for a number of other special methods. In particular

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What if use None and NotImplemented as different signals: "not defined here so fall back on either a superclass or a different protocol", and "not defined here so fail without falling back"? -- ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Guido van Rossum
Guido van Rossum added the comment: No. Simply No. Nobody will be able to remember which means which. -- ___ Python tracker ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: True, even I were not sure which should mean which. ;) > When I manually trigger the code in typeobject.c:5827, I get a segfault; I'm surprised no test triggered that. I think this triggered one of Victor's guards, added to catch such sort of errors. In

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Guido van Rossum
Guido van Rossum added the comment: FWIW, Martin's review was much more extensive. I'm looking forward to the flat version of your next patch, Andrew! -- ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Guido van Rossum
Guido van Rossum added the comment: In response to Serhiy's comment regarding __copy__ etc.: while the distinction is somewhat unfortunate, I think it's too late to make this more consistent. I think it's fine that the special methods used by copy and pickle protocols behave somewhat differently

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Guido van Rossum
Guido van Rossum added the comment: The idea of using NotImplemented was already discussed (IIR in python-ideas). I really don't like it. -- ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Without tests you can't be sure that there is no special case in some abstract classes or operators, or that it can't be introduced in future. To decrease the copy-pasting you can use code generation for testing. But I don't know what is the best place for

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Guido van Rossum
Guido van Rossum added the comment: I propose to solve the narrow problem by indeed supporting the setting of certain special methods to None similar to __hash__. This should be limited to those methods for which this adds value, e.g. where the complete absence of the method causes a

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Guido van Rossum
Guido van Rossum added the comment: I like all of that. Thanks! -- ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Andrew Barnert
Andrew Barnert added the comment: Is an hg export patch usable? If not, let me know and I'll flatten it. Anyway, the attached patch fixes #25987 and #25864 as well as this one, as follows: * Every ABC in collections.abc that has a subclass hook now treats None as blocking, instead of a few

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Andrew Barnert
Andrew Barnert added the comment: > A Mercurial export patch should work with the Reitveld review thing if it is > a single revision (and based on a public revision). Well, it's 7 separate commits on a work branch, so I could check in each piece and test it separately, and then I just

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-04 Thread Martin Panter
Martin Panter added the comment: A Mercurial export patch should work with the Reitveld review thing if it is a single revision (and based on a public revision). Or you could try getting a plain diff from the base revision. Or for changes that are independent, separate patches based off a

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-01 Thread Andrew Barnert
Andrew Barnert added the comment: > I don’t think you need to define __len__() to get an iterable, only > __getitem__(). The "old-style sequence protocol" means having a __getitem__ that works for values from 0 to __len__() and raises IndexError at __len__(). You don't need to be a complete

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-01 Thread Andrew Barnert
Andrew Barnert added the comment: > Also, if I understand your problem, Container would also be susceptible in > theory You're right, but not in the details. Being iterable (whether via __iter__ or via the old-style sequence protocol) makes you a container. But, again, false negatives for

[issue25958] Implicit ABCs have no means of "anti-registration"

2016-01-01 Thread R. David Murray
R. David Murray added the comment: Absolutely you do not need to define __len__ to get an iterable. Length is not a property of an iterable (iterables can be indefinite in length or infinite in length). -- nosy: +r.david.murray ___ Python tracker

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-31 Thread Martin Panter
Martin Panter added the comment: I don’t think you need to define __len__() to get an iterable, only __getitem__(). Also, if I understand your problem, Container would also be susceptible in theory, because membership testing via “in” and “not in” falls back to iteration. If you only define

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-28 Thread Andrew Barnert
Andrew Barnert added the comment: Hashable and Awaitable already treat None (actually any falsey value) as not implementing the special method, and blocking any superclass implementation, in their __subclasshook__. (This only blocks implicit subclassing--anything that actually directly or

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: As Guido pointed out on -ideas, hashing already uses the convention of `__hash__ is None` to declare a type unhashable, and `collections.abc.Hashable.__subclasshook__` already checks for that. Meanwhile, setting `__iter__` and `__reversed__` to `None` already

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Andrew Barnert
New submission from Andrew Barnert: Serhiy Storchaka raised an issue (http://bugs.python.org/msg256910) with static type hints on #25864 (http://bugs.python.org/issue25864), which I believe also applies to runtime ABCs. Consider this class, which uses `[]` in a way similar to generic types:

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Andrew Barnert
Andrew Barnert added the comment: As Serhiy pointed out on -ideas, there's no reason `reversed` couldn't add special handling for `__reversed__ is None`, akin to `hash`'s special handling for `__hash__ is None`, to produce whatever error message we wanted in the `TypeError`, instead of

[issue25958] Implicit ABCs have no means of "anti-registration"

2015-12-26 Thread Nick Coghlan
Changes by Nick Coghlan : -- nosy: +ncoghlan ___ Python tracker ___ ___ Python-bugs-list