[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you, Nikita!

--
resolution:  -> fixed
stage: test needed -> 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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 74d1663580d1914bd110c3ab7282451f5e2cd2b5 by Nikita Sobolev in 
branch 'main':
bpo-46296: [Enum] add a test for missing `value` recovery (GH-30458)
https://github.com/python/cpython/commit/74d1663580d1914bd110c3ab7282451f5e2cd2b5


--

___
Python tracker 

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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Yes, this is just a missing test. Not a wrong condition!

--
components: +Tests -Library (Lib)

___
Python tracker 

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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Ethan Furman


Change by Ethan Furman :


--
Removed message: https://bugs.python.org/msg410029

___
Python tracker 

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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Ethan Furman


Ethan Furman  added the comment:

Looking through some of my code that prompted that branch, the issue is caused 
when `_generate_next_value_` modifies the given args -- when `__set_name__` 
runs it has no way of getting the same results to automatically create the 
`_value_` attribute.

--

___
Python tracker 

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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Ethan Furman


Ethan Furman  added the comment:

(2) is false.

>>> from enum import Enum
>>> 
>>> class MyEnum(Enum):
... def __new__(cls, value):
... member = object.__new__(cls)
... return member
... ONE = 1
... 

>>> MyEnum.ONE
MyEnum.ONE

>>> MyEnum._use_args_
True

>>> MyEnum._member_type_


If coverage shows a branch not being tested, design a test for it instead of 
removing the branch.

--
assignee:  -> ethan.furman
nosy: +ethan.furman
stage: patch review -> test needed

___
Python tracker 

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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
keywords: +patch
pull_requests: +28661
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30458

___
Python tracker 

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



[issue46296] Unreachable condition: `if enum_class._member_type_ is object`

2022-01-07 Thread Nikita Sobolev


New submission from Nikita Sobolev :

This condition can never be `True`: 
https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Lib/enum.py#L222-L223

Why? Because: 
1. It is executed only when `if not enum_class._use_args_:`: 
https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Lib/enum.py#L215
2. But, `enum_class._use_args_` will always be `False` for cases when 
`enum_class._member_type_` is `object`
3. It is defined here: 
https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Lib/enum.py#L937

So, I guess that removing this condition can simplify the `enum.py`.
Coverage shows that this part is not tested.

I will send a PR shortly.

--
components: Library (Lib)
messages: 409989
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Unreachable condition: `if enum_class._member_type_ is object`
versions: Python 3.11

___
Python tracker 

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