Ethan Furman added the comment:
Thank you to everyone involved. :-)
To answer the first three points that started this issue:
1. iteration -> each single-bit flag in the entire flag, or a
combinations of flags, is returned one at a time -- not the
empty set, not other multi-bit val
Ethan Furman added the comment:
New changeset 7aaeb2a3d682ecba125c33511e4b4796021d2f82 by Ethan Furman in
branch 'master':
bpo-38250: [Enum] single-bit flags are canonical (GH-24215)
https://github.com/python/cpython/commit/7aaeb2a3d682ecba125c33511e4b4796021d2f82
Ethan Furman added the comment:
This issue is not unique to Enum, and is not an Enum problem.
What is happening is that "test.py" has the `__name__` of `__main__` because it
is being directly executed from the command line, but when `test2.py` imports
it, it is being r
Ethan Furman added the comment:
The code sample:
class Color(IntFlag):
BLACK = 0
RED = 1
GREEN = 2
BLUE = 4
PURPLE = RED | BLUE
WHITE = RED | GREEN | BLUE
Here's the summary of the changes:
- single-bit flags are canonical
- multi-bit
Change by Ethan Furman :
--
pull_requests: +23042
pull_request: https://github.com/python/cpython/pull/24215
___
Python tracker
<https://bugs.python.org/issue38
Ethan Furman added the comment:
Final outcome:
`Flag` has been redesigned such that any flag comprised of a single bit is
canonical; flags comprised of multiple bits are considered aliases. During
iteration only canonical flags are returned.
--
resolution: -> fixed
stage: pa
Ethan Furman added the comment:
Yes.
--
___
Python tracker
<https://bugs.python.org/issue42915>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
New changeset c314e60388282d9829762fb6c30b12e2807caa19 by Ethan Furman in
branch 'master':
bpo-42901: [Enum] move member creation to `__set_name__` (GH-24196)
https://github.com/python/cpython/commit/c314e60388282d9829762fb6c30b12e2807caa19
Ethan Furman added the comment:
I just finished a rewrite of Flag for 3.10. Using your test below I was able
to tweak the rewrite so the final numbers are:
Took normal 0.148092 seconds.
Took cached 0.017438 seconds.
Your original post had a ratio of nearly 200 -- it is now 8.7ish
Ethan Furman added the comment:
If an optimization changes semantics it's not an optimization.
In `if x: pass` how do we know `x` is falsely without calling `bool()` on it?
---
On a slightly different note, in the code:
if a and b:
...
why is `bool(a)` called twice
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +23022
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/24196
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
Nick Coghlan made the observation that `__set_name__` should be doing what is
currently the after-new work.
Tracking in #42901.
--
keywords: -patch
resolution: -> rejected
stage: patch review -> resolved
status: open -> closed
superseder:
New submission from Ethan Furman :
In discussions about moving the calls to `__set_name__` and
`__init_subclass__`, Nick Coughlan made an observation:
Nick Coghlan:
> Both EnumMeta and ABCMeta should probably be relying on `__set_name__`
> for their per-member set up work these days,
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.9
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset 9ab4dd452287169f08a8cf4d4c68c2139f8de714 by Ethan Furman in
branch '3.9':
[3.9] bpo-42851: [Enum] remove brittle __init_subclass__ support (GH-24154)
(GH-24155)
https://github.com/python/cpython/commit/9ab4dd452287169f08a8cf4d4c68c2139f8de714
Change by Ethan Furman :
--
pull_requests: +22983
pull_request: https://github.com/python/cpython/pull/24155
___
Python tracker
<https://bugs.python.org/issue42
Ethan Furman added the comment:
New changeset a581a868d97f649aedf868a1d27865a10925c73a by Ethan Furman in
branch 'master':
bpo-42851: [Enum] remove brittle __init_subclass__ support (GH-24154)
https://github.com/python/cpython/commit/a581a868d97f649aedf868a1d27865a10925c73a
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22982
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/24154
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
That would be due to some changes to try and get `Enum` and `__init_subclass__`
to work together.
I'll revert those changes. Thank you for the report.
--
assignee: -> ethan.furman
priority: normal ->
Ethan Furman added the comment:
Guido, I just wanted to get it all in place while it was fresh in my mind.
Actual code tends to make a discussion easier. I'll make sure and transcribe
any relevant discussion from python-dev to here
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22829
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23986
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
nosy: +ncoghlan
___
Python tracker
<https://bugs.python.org/issue42775>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
My understanding of using keywords in class headers
class MyClass(SomeBaseClass, setting='maybe'):
...
is that the keywords would get passed into the super classes
`__init_subclass__` (`SomeBaseClass` and `setting`).
However, in the cases
New submission from Ethan Furman :
PEP 487 introduced __init_subclass__ and __set_name__, and both of those were
wins for the common cases of metaclass usage.
Unfortunately, the implementation of PEP 487 with regards to __init_subclass__
has made the writing of correct metaclasses
Ethan Furman added the comment:
If the patch in issue42775 is committed, this problem will be solved.
--
assignee: -> ethan.furman
superseder: -> __init_subclass__ should be called in __init__
___
Python tracker
<https://bugs.p
Change by Ethan Furman :
--
pull_requests: -22792
___
Python tracker
<https://bugs.python.org/issue42727>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
New changeset 786d97a66cac48e7a933010367b8993a5b3ab85b by Ethan Furman in
branch 'master':
bpo-42727: [Enum] use super() and include **kwds (GH-23927)
https://github.com/python/cpython/commit/786d97a66cac48e7a933010367b8993a5b3ab85b
Change by Ethan Furman :
--
pull_requests: +22778
pull_request: https://github.com/python/cpython/pull/23927
___
Python tracker
<https://bugs.python.org/issue42
New submission from Ethan Furman :
The two subclasses in the test script are not calling super(). When they do,
both __init_subclasses__ are called.
--
nosy: +ethan.furman
resolution: -> not a bug
stage: -> resolved
status: open -&g
Change by Ethan Furman :
--
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue41644>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
New changeset f7dca9b9c864c1b7807014ea21a30cac76727e8b by Ethan Furman in
branch '3.9':
[3.9] bpo-42727: [Enum] EnumMeta.__prepare__ now accepts **kwds (GH-23917).
(GH-23926)
https://github.com/python/cpython/commit/f7dca9b9c864c1b7807014ea21a30cac76727e8b
Ethan Furman added the comment:
I just added **kwds to EnumMeta -- can this be closed?
--
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue38
Ethan Furman added the comment:
A use-case for writable bases:
__init_subclass__ is called in type.__new__, which means that for Enum
__init_subclass__ is called before the members have been added. To work around
this I am currently (3.10) adding in a _NoInitSubclass to the bases before
Change by Ethan Furman :
--
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue32501>
___
___
Python-bugs-list mailing list
Unsubscribe:
Ethan Furman added the comment:
I tried update `abc.py` with the same dance I have to use with `Enum`:
def __new__(mcls, name, bases, namespace, **kwargs):
# remove current __init_subclass__ so previous one can be found with
getattr
try:
new_init_subclass
Change by Ethan Furman :
--
pull_requests: +22777
pull_request: https://github.com/python/cpython/pull/23926
___
Python tracker
<https://bugs.python.org/issue42
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22768
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/23917
___
Python tracker
<https://bugs.python.org/issu
New submission from Ethan Furman :
**kwds are necessary to support __init_subclass__, but __prepare__ currently
does not accept them.
--
assignee: ethan.furman
messages: 383670
nosy: ethan.furman
priority: normal
severity: normal
status: open
title: [Enum] EnumMeta.__prepare__ needs
Change by Ethan Furman :
--
nosy: +ethan.furman
___
Python tracker
<https://bugs.python.org/issue35815>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Ethan Furman :
--
assignee: ethan.furman
components: Library (Lib)
nosy: ethan.furman
priority: normal
severity: normal
stage: needs patch
status: open
title: [Enum] _sunder_ methods only looked up in the last Enum class in the mro
type: behavior
versions: Python 3.10, Python
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset 9d1fff1fcd5332f0ba7f72d0e0f9f66b47ec4e8d by Ethan Furman in
branch '3.9':
[3.9] bpo-42567: [Enum] call __init_subclass__ after members are added
(GH-23714) (GH-23772)
https://github.com/python/cpython/commit
Change by Ethan Furman :
--
pull_requests: +22628
stage: backport needed -> patch review
pull_request: https://github.com/python/cpython/pull/23772
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.9
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset aba12b67c18b17bb727a0d50dd0653e38cb64dc8 by Miss Islington (bot)
in branch '3.9':
[3.9] bpo-42517: [Enum] deprecate private name members (GH-23722) (GH-23748)
https://github.com/python/cpython/commit/aba12b67c18b17bb727a0d50dd0653e38cb64dc8
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset b5a6db9111562454617b6771b61f2734ea0420c9 by Ethan Furman in
branch 'master':
bpo-39717: [tarfile] update nested exception raising (GH-23739)
https://github.com/python/cpython/commit/b5a6db9111562454617b6771b61f2734ea0420c9
Change by Ethan Furman :
--
versions: +Python 3.10 -Python 3.9
___
Python tracker
<https://bugs.python.org/issue39717>
___
___
Python-bugs-list mailing list
Unsub
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22597
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/23739
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset a65828717982e6a56382d7aff738478f5b5b25d0 by Ethan Furman in
branch 'master':
bpo-34750: [Enum] add `_EnumDict.update()` support (GH-23725)
https://github.com/python/cpython/commit/a65828717982e6a56382d7aff738478f5b5b25d0
Ethan Furman added the comment:
Thank you for finding that, Antony.
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset efb13be72cbf49edf591936fafb120fe1b7d59f7 by Ethan Furman in
branch 'master':
bpo-42385: [Enum] add `_generate_next_value_` to StrEnum (GH-23735)
https://github.com/python/cpython/commit/efb13be72cbf49edf591936fafb120fe1b7d59f7
Change by Ethan Furman :
--
pull_requests: +22594
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23735
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
stage: patch review -> needs patch
title: Should enum.auto's behavior be adjusted for StrEnum to return the enum
name? -> adjust enum.auto's behavior for StrEnum to return the enum name
___
Python tracker
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22587
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23727
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset 7cf0aad96d1d20f07d7f0e374885f327c2d5ff27 by Ethan Furman in
branch 'master':
bpo-42517: [Enum] do not convert private names into members (GH-23722)
https://github.com/python/cpython/commit/7cf0aad96d1d20f07d7f0e374885f327c2d5ff27
Change by Ethan Furman :
--
stage: patch review -> backport needed
versions: +Python 3.9
___
Python tracker
<https://bugs.python.org/issue42567>
___
___
Py
Ethan Furman added the comment:
New changeset 6bd94de168b58ac9358277ed6f200490ab26c174 by Ethan Furman in
branch 'master':
bpo-42567: [Enum] call __init_subclass__ after members are added (GH-23714)
https://github.com/python/cpython/commit/6bd94de168b58ac9358277ed6f200490ab26c174
Ethan Furman added the comment:
Okay, you convinced me. I would ask two things, though:
- use vars() instead of locals()
- split the one-liner ;)
class Foo(Enum):
vars().update({
k: v
for k, v in foo_defines.items
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22586
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23725
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
stage: -> needs patch
type: -> enhancement
versions: +Python 3.10 -Python 3.8
___
Python tracker
<https://bugs.python.org/i
Ethan Furman added the comment:
New changeset f6d1520219899874d78e7710934c9b21af880f9a by Miss Islington (bot)
in branch '3.8':
bpo-40084: [Enum] dir() includes member attributes (GH-19219) (GH-22853)
https://github.com/python/cpython/commit/f6d1520219899874d78e7710934c9b21af880f9a
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22583
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23722
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
Make that deprecate in 3.9, work correctly in 3.10.
--
___
Python tracker
<https://bugs.python.org/issue42517>
___
___
Python-bug
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +22576
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23714
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset cbfcc67170d459bcf3e9d63d2f44eadec740bf69 by Miss Islington (bot)
in branch '3.8':
bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497) (GH-23704)
https://github.com/python/cpython/commit/cbfcc67170d459bcf3e9d63d2f44eadec740bf69
Ethan Furman added the comment:
New changeset 14eaa7d75282d8458455c41e9e871c56db8b9a10 by Miss Islington (bot)
in branch '3.9':
bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497) (GH-23703)
https://github.com/python/cpython/commit/14eaa7d75282d8458455c41e9e871c56db8b9a10
Ethan Furman added the comment:
New changeset 37440eef7f9a0c27e13fc9ce0850574bb00688b0 by Ethan Furman in
branch 'master':
bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497)
https://github.com/python/cpython/commit/37440eef7f9a0c27e13fc9ce0850574bb00688b0
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset be52ca45d9eb9c3e8941e46ddc67a210f0f4c6fa by Miss Islington (bot)
in branch '3.9':
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487) (GH-23673)
https://github.com/python/cpython/commit/be52ca45d9eb9c3e8941e46ddc67a210f0f4c6fa
Ethan Furman added the comment:
New changeset 699e5e448919283578afe445069ab93b34bf8eae by Miss Islington (bot)
in branch '3.8':
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487) (GH-23672)
https://github.com/python/cpython/commit/699e5e448919283578afe445069ab93b34bf8eae
Ethan Furman added the comment:
New changeset c266736ec1f9ebef38b134ceb4832df015711b38 by Ethan Furman in
branch 'master':
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487)
https://github.com/python/cpython/commit/c266736ec1f9ebef38b134ceb4832df015711b38
New submission from Ethan Furman :
__init_subclass__ is being automatically called when the initial Enum is
created, but before the members have been added, greatly reducing that method's
usefulness.
--
assignee: ethan.furman
components: Library (Lib)
messages: 382489
nosy
New submission from Ethan Furman :
Currently, private names such as '__location' will get both name mangled and
converted into an attribute, while `__location_` will get mangled, but not
converted as the final name is sundered (e.g. `_MyEnum__location_`).
Just in case anyone is actually
Ethan Furman added the comment:
A good idea.
Since the Python opinion of enum members is that they be upper-cased, and every
magic string constant I have seen is lower-case,
`StrEnum._generate_next_value_` should lower case the name. Users can
substitute their own `_gnv_` for different
Ethan Furman added the comment:
Python-Dev thread [0], summary below:
> As you may have noticed, Enums are starting to pop up all
> over the stdlib [1].
>
> To facilitate transforming existing module constants to
> IntEnums there is `IntEnum._convert_`. In Issue36548 [2]
&g
Change by Ethan Furman :
--
components: +Library (Lib) -Interpreter Core
___
Python tracker
<https://bugs.python.org/issue41907>
___
___
Python-bugs-list mailin
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +21515
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/22497
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
Thank you for the bug report.
Another solution would be to subclass IntFlag and specify the `__format__`
method:
from enum import IntFlag as _IntFlag
class IntFlag(_IntFlag):
def __format__(self, spec):
return format(self.value
Change by Ethan Furman :
--
assignee: -> ethan.furman
___
Python tracker
<https://bugs.python.org/issue41889>
___
___
Python-bugs-list mailing list
Unsubscrib
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +21505
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/22487
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
At this point, the PR has made the following changes:
- normal Enums
- repr() -> "classname.membername"
- str() -> "membername"
- stdlib Enums available as module attributes (RegexFlag, AddressFamily, etc.)
- repr() -> &q
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +21433
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/22392
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset 64362c2e435eddc5e84cea313d92bc0b96d227f7 by Miss Islington (bot)
in branch '3.9':
bpo-37062: Enum: add extended AutoNumber example (GH-22349) (GH-22370)
https://github.com/python/cpython/commit/64362c2e435eddc5e84cea313d92bc0b96d227f7
Ethan Furman added the comment:
Thank you, Reuben!
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset 5acc1b5f0b62eef3258e4bc31eba3b9c659108c9 by Miss Islington (bot)
in branch '3.8':
bpo-37062: Enum: add extended AutoNumber example (GH-22349) (GH-22369)
https://github.com/python/cpython/commit/5acc1b5f0b62eef3258e4bc31eba3b9c659108c9
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
Thank you for your help, Serhiy!
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Ethan Furman added the comment:
New changeset d986d1657e1e7b50807d0633cb31d96a2d866d42 by Ethan Furman in
branch 'master':
bpo-41816: `StrEnum.__str__` is `str.__str__` (GH-22362)
https://github.com/python/cpython/commit/d986d1657e1e7b50807d0633cb31d96a2d866d42
Ethan Furman added the comment:
New changeset ea0711a9f9f207d6d4ca037d90de6ec60db131b0 by Ethan Furman in
branch 'master':
bpo-41817: use new StrEnum to ensure all members are strings (GH-22348)
https://github.com/python/cpython/commit/ea0711a9f9f207d6d4ca037d90de6ec60db131b0
Change by Ethan Furman :
--
pull_requests: +21400
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/22362
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
>From Serhiy Storchaka:
-
The only exception is StrEnum -- overriding __str__ of str
subclass may be not safe. Some code will call str() implicitly, other
will read the string content of the object directly, and they will be
differ
Change by Ethan Furman :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +21388
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/22349
___
Python tracker
<https://bugs.python.org/issu
Change by Ethan Furman :
--
keywords: +patch
pull_requests: +21387
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/22348
___
Python tracker
<https://bugs.python.org/issu
Ethan Furman added the comment:
New changeset 0063ff4e583505e69473caa978e476ea4c559b83 by Ethan Furman in
branch 'master':
bpo-41816: add `StrEnum` (GH-22337)
https://github.com/python/cpython/commit/0063ff4e583505e69473caa978e476ea4c559b83
Ethan Furman added the comment:
The only `AutoNumber` in the stdlib is as an example in the docs. Were you
thinking of something else?
--
versions: +Python 3.10 -Python 3.9
___
Python tracker
<https://bugs.python.org/issue37
301 - 400 of 1854 matches
Mail list logo