[issue19022] Improve handling of type.__abstractmethods__ descriptor

2021-11-29 Thread Irit Katriel


Change by Irit Katriel :


--
components: +Interpreter Core

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19022] Improve handling of type.__abstractmethods__ descriptor

2021-11-29 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19022] Improve handling of type.__abstractmethods__ descriptor

2013-09-22 Thread Daniel Urban

Daniel Urban added the comment:

I like the 3rd alternative the most. It seems to me, that __abstractmethods__ 
is currently an undocumented implementation detail of ABCs. The 1st alternative 
would cause every type to have an empty __abstractmethods__ (which is 
technically correct, but probably not very useful). It seems to me that the 2nd 
alternative would not help very much in the original problem mentioned in 
issue10006 (automatically looking up every name found in dir). So I think, that 
the best would be to fix type.__dir__ this way. (Although, if we really want to 
document and use __abstractmethods__ on every type, then of course we should do 
the 1st alternative.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19022] Improve handling of type.__abstractmethods__ descriptor

2013-09-15 Thread Nick Coghlan

New submission from Nick Coghlan:

Issue 10006 pointed out that attempting to access object.__abstractmethods__ 
raises AttributeError. The solution was to ensure type.__abstractmethods__ 
*also* raises AttributeError.

This is thoroughly confusing, since the name is clearly visible in the output 
of dir(type). While it's technically legal for a descriptor to always raise 
AttributeError, breaking the following typical assumed invariant is *highly* 
dubious:

all(hasattr(obj, x) for x in dir(obj))

I see three main alternatives for improving the situation:

1. Make __abstractmethods__ a read-only descriptor that returns something 
meaningful (like a frozenset(), the same as you get if you inherit from 
abc.ABCMeta without defining any abstract methods)

2. Throw a better exception message that explains the broken invariant rather 
than the generic "AttributeError with attribute name" that is currently thrown.

3. Implement type.__dir__ to filter out the uncooperative descriptor

--
messages: 197755
nosy: ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Improve handling of type.__abstractmethods__ descriptor
type: behavior
versions: Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19022] Improve handling of type.__abstractmethods__ descriptor

2013-09-15 Thread Nick Coghlan

Changes by Nick Coghlan :


--
nosy: +Yaroslav.Halchenko, benjamin.peterson, daniel.urban

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com