[issue34487] enum _sunder_ names mix metaclass and enum class attributes

2018-08-24 Thread Gerrit Holl

New submission from Gerrit Holl :

In the [`enum` 
module](https://docs.python.org/3/library/enum.html#supported-sunder-names) 
documentation, some of the `_sunder_` names are on `EnumMeta`, whereas others 
are on the produced `Enum` class:

> 8.13.15.3.2. Supported `_sunder_` names

> * `_name_` – name of the member
> * `_value_` – value of the member; can be set / modified in __new__
> * `_missing_` – a lookup function used when a value is not found; may be 
> overridden
> * `_ignore_` – a list of names, either as a list() or a str(), that will not 
> be transformed into members, and will be removed from the final class
> * `_order_` – used in Python 2/3 code to ensure member order is consistent 
> (class attribute, removed during class creation)
> * `_generate_next_value_` – used by the Functional API and by auto to get an 
> appropriate value for an enum member; may be overridden

Experimentally, it appears `_name_` and `_value_` are on the `Enum` class, 
whereas the others are all on the `EnumMeta` class:

In [272]: class Test(enum.Enum): a = 0

In [273]: Test.a._name_
Out[273]: 'a'

In [274]: Test._name
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 Test._name

/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/envs/FCDR37a/lib/python3.7/enum.py
 in __getattr__(cls, name)
344 return cls._member_map_[name]
345 except KeyError:
--> 346 raise AttributeError(name) from None
347 
348 def __getitem__(cls, name):

AttributeError: _name

In [275]: Test.a._value_
Out[275]: 0

In [276]: Test._value
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 Test._value

/group_workspaces/cems2/fiduceo/Users/gholl/anaconda3/envs/FCDR37a/lib/python3.7/enum.py
 in __getattr__(cls, name)
344 return cls._member_map_[name]
345 except KeyError:
--> 346 raise AttributeError(name) from None
347 
348 def __getitem__(cls, name):

AttributeError: _value

In [277]: Test.a._missing_
Out[277]: >

In [278]: Test._missing_
Out[278]: >


This is not clear from the documentation.

--
assignee: docs@python
components: Documentation
messages: 324003
nosy: Gerrit.Holl, docs@python
priority: normal
severity: normal
status: open
title: enum _sunder_ names mix metaclass and enum class attributes
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34487] enum _sunder_ names mix metaclass and enum class attributes

2018-08-27 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue34487] enum _sunder_ names mix metaclass and enum class attributes

2018-08-27 Thread INADA Naoki


INADA Naoki  added the comment:

Is it really need to be documented?
How is it important when using enum?

If there are no problem, I prefer keeping it implementation detail and don't 
make document fatter.

--
nosy: +inada.naoki

___
Python tracker 

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



[issue34487] enum _sunder_ names mix metaclass and enum class attributes

2018-08-27 Thread Ethan Furman


Ethan Furman  added the comment:

All those attributes live in the Enum class.  If you use a non-existent 
attribute, such as _name, then the metaclass will be called to check if that 
name is actually an Enum member.

--
assignee: docs@python -> ethan.furman
nosy: +ethan.furman

___
Python tracker 

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



[issue34487] enum _sunder_ names mix metaclass and enum class attributes

2018-09-10 Thread Ethan Furman


Change by Ethan Furman :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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