[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread Ethan Furman
Ethan Furman added the comment: There was an effort to make it so `_generate_next_value_` could be defined last and still work correctly -- unfortunately, it could not handle the more common case of using `auto()` with the default `_generate_next_value_`: class I(Enum): first =

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread miss-islington
Change by miss-islington : -- pull_requests: +21338 pull_request: https://github.com/python/cpython/pull/22287 ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread miss-islington
Change by miss-islington : -- pull_requests: +21339 pull_request: https://github.com/python/cpython/pull/22286 ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread Ethan Furman
Change by Ethan Furman : -- pull_requests: +21337 pull_request: https://github.com/python/cpython/pull/22285 ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-09-16 Thread Ethan Furman
Change by Ethan Furman : -- pull_requests: +21336 pull_request: https://github.com/python/cpython/pull/22284 ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-06-21 Thread Ethan Furman
Ethan Furman added the comment: Not yet. I want to investigate the idea Ankesh Saha had some more. -- versions: +Python 3.10 -Python 3.7, Python 3.8, Python 3.9 ___ Python tracker

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-06-21 Thread శ్రీనివాస్ రెడ్డి తాటిపర్తి
Srinivas Reddy Thatiparthy(శ్రీనివాస్ రెడ్డి తాటిపర్తి) added the comment: We can close this? -- nosy: +thatiparthy ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-06-11 Thread Ethan Furman
Ethan Furman added the comment: New changeset ebd44003c9e206755e5e28716242ed8941495a62 by Miss Islington (bot) in branch '3.7': bpo-40025: Require _generate_next_value_ to be defined before members (GH-19762) https://github.com/python/cpython/commit/ebd44003c9e206755e5e28716242ed8941495a62

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-05-27 Thread Ethan Furman
Ethan Furman added the comment: New changeset b5ecbf02e4dbdea6d1c9a6d7189137f76e70c073 by Miss Islington (bot) in branch '3.8': bpo-40025: Require _generate_next_value_ to be defined before members(GH-19763) https://github.com/python/cpython/commit/b5ecbf02e4dbdea6d1c9a6d7189137f76e70c073

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-05-04 Thread hongweipeng
Change by hongweipeng : -- nosy: +hongweipeng nosy_count: 9.0 -> 10.0 pull_requests: +19219 pull_request: https://github.com/python/cpython/pull/19904 ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-04-28 Thread miss-islington
Change by miss-islington : -- pull_requests: +19084 pull_request: https://github.com/python/cpython/pull/19763 ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-04-28 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 8.0 -> 9.0 pull_requests: +19083 pull_request: https://github.com/python/cpython/pull/19762 ___ Python tracker

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-04-28 Thread Ethan Furman
Ethan Furman added the comment: New changeset d9a43e20facdf4ad10186f820601c6580e1baa80 by Ethan Onstott in branch 'master': bpo-40025: Require _generate_next_value_ to be defined before members (GH-19098) https://github.com/python/cpython/commit/d9a43e20facdf4ad10186f820601c6580e1baa80

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-04-28 Thread Ethan Onstott
Ethan Onstott added the comment: Ankesh, that is the expected behavior as no patch has been merged yet. -- ___ Python tracker ___

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-30 Thread Ankesh Saha
Ankesh Saha added the comment: Hi, I have ran the code with with _generate_next_value_ method at the bottom of the class and didn't run into any exceptions. Please refer my python file. Please let me know if I am missing something. from enum import Enum, auto class E(Enum): A =

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-24 Thread Jonathan Hsu
Jonathan Hsu added the comment: Thank you for the explanation. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-21 Thread Ethan Furman
Ethan Furman added the comment: Jonathan Hsu, you are correct -- and "don't do that" was my initial response; but Enum takes many pains to make sure the user doesn't shoot themselves in the foot, so raising a TypeError is appropriate instead of silently doing the wrong thing. --

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-21 Thread Jonathan Hsu
Jonathan Hsu added the comment: While the current behavior may be initially unexpected, it does match the way that python normally behaves when defining class variables. For example, the following class will throw an exception because the function number_two() is called before it is

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-20 Thread Ethan Onstott
Change by Ethan Onstott : -- keywords: +patch nosy: +Ethan Onstott nosy_count: 5.0 -> 6.0 pull_requests: +18458 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/19098 ___ Python tracker

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-20 Thread Ethan Furman
Ethan Furman added the comment: Immediate solution is to raise an exception if `_generate_next_value_` is defined after members. Possible future solution is to save all member definitions until after class is defined. The exception-raising solution would require a check in `_EnumDict`

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-20 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +barry, eli.bendersky, ethan.furman ___ Python tracker ___ ___ Python-bugs-list

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-20 Thread Luis E.
Change by Luis E. : -- components: -Documentation ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40025] enum: _generate_next_value_ is not called if its definition occurs after calls to auto()

2020-03-20 Thread Luis E.
New submission from Luis E. : I ran into this issue when attempting to add a custom _generate_next_value_ method to an existing Enum. Adding the method definition to the bottom of the class causes it to not be called at all: from enum import Enum, auto class E(Enum): A = auto()