New submission from Gabriel Tremblay <gabr...@delvelabs.ca>:

Types under the typing module used to behave like other python classes 
regarding the __name__ attribute before Python 3.7. The behavior seems to have 
changed to a non-standard way.

Py3.6 
>>> from typing import List
>>> dir(List)
['__abstractmethods__', '__add__', '__args__', '__class__', '__contains__', 
'__delattr__', '__delitem__', 
'__dir__', '__doc__', '__eq__', '__extra__', '__format__', '__ge__', 
'__getattribute__', '__getitem__', '_
_gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', 
'__iter__', '__le__', '__len_
_', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__next_in_mro__', 
'__orig_bases__', '__origin
__', '__parameters__', '__reduce__', '__reduce_ex__', '__repr__', 
'__reversed__', '__rmul__', '__setattr__
', '__setitem__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', 
'__tree_hash__', '_abc_cache',
 '_abc_negative_cache', '_abc_negative_cache_version', '_abc_registry', 
'append', 'clear', 'copy', 'count'
, 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> List.__name__
'List'


Py3.7:
>>> from typing import List
>>> dir(List)
['__args__', '__call__', '__class__', '__delattr__', '__dict__', '__dir__', 
'__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', 
'__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', 
'__instancecheck__', '__le__', '__lt__', '__module__', '__mro_entries__', 
'__ne__', '__new__', '__origin__', '__parameters__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', 
'__str__', '__subclasscheck__', '__subclasshook__', '__weakref__', '_inst', 
'_name', '_special', 'copy_with']
>>> List.__name__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/typing.py", line 699, in __getattr__
    raise AttributeError(attr)
AttributeError: __name__
>>> List._name
'List'

----------
components: Interpreter Core
messages: 323663
nosy: Gabriel Tremblay
priority: normal
severity: normal
status: open
title: __name__ not available for classes in typing module
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34422>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to