Ethan Furman <et...@stoneleaf.us> added the comment:
That new example looks great! Note that you don't need the parenthesis, though.
FYI: The same thing using the aenum library* would look like:
from aenum import Enum
class Coord(bytes, Enum):
_init_ = 'value label unit'
Ethan Furman <et...@stoneleaf.us> added the comment:
Setting _value_ needs to happen in __new__ for those cases where another data
type, such as str or int, is mixed in.
I'll look at adding an example to the docs.
Thanks for the report!
--
assignee: -> ethan.furman
c
Ethan Furman <et...@stoneleaf.us> added the comment:
Rahul Jha, sure, go ahead!
--
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python
Ethan Furman <et...@stoneleaf.us> added the comment:
New changeset b8e21f12891382bc0aac5ccd13dcb4a990d65e0a by Ethan Furman
(anentropic) in branch 'master':
bpo-31947: remove None default for names param in Enum._create_ (GH-4288)
https://github.com/python/cpython/
Ethan Furman <et...@stoneleaf.us> added the comment:
DeprecationWarning is in 3.7, now need to raise TypeError in 3.8.
--
stage: patch review -> needs patch
versions: -Python 3.6
___
Python tracker <rep...@bugs.python.org>
<https
Ethan Furman <et...@stoneleaf.us> added the comment:
This and issue33217 are similar enough I'm going to track it in issue33217.
--
resolution: -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder: -> x in enum.Flag member is True wh
Ethan Furman <et...@stoneleaf.us> added the comment:
New changeset 3715176557cf87925c8f89b98939c7daf9bf48e2 by Ethan Furman in
branch '3.7':
[3.7] bpo-33217: deprecate non-Enum lookups in Enums (GH-6392)
https://github.com/python/cpython/commit/3715176557cf87925c8f89b98939c7daf9
Change by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33233>
___
_
Change by Ethan Furman <et...@stoneleaf.us>:
--
keywords: +patch
pull_requests: +6100
stage: -> patch review
___
Python tracker <rep...@bugs.python.org>
<https://bugs.pyt
Ethan Furman <et...@stoneleaf.us> added the comment:
issue33217 is tracking member-containment checks; modifying this one to track
class-containment checks.
Given
class Color(Enum):
RED = 1
class Fruit(Enum):
APPLE = 1
then
--> Fruit.APPLE in Color
False
-->
Ethan Furman <et...@stoneleaf.us> added the comment:
Nitish, Flag can check if the current Flag class has a mixin, and if so if the
object being checked for is of that same type.
Dutcho, my apologies. Looks like I did not fully understand how __contains__
is supposed to work and a Typ
Ethan Furman <et...@stoneleaf.us> added the comment:
Stepping back slightly, it is more general to say that str, and in certain
other cases dict and set (and possibly others) will raise instead of return
False when it is impossible for the target type to ever hold the checked-for
Ethan Furman <et...@stoneleaf.us> added the comment:
Strings are actually the odd-man out -- dicts, sets, lists, tuples, etc., all
return False instead of raising TypeError.
The reason str raises an error is because `in`, for str, is a substring check,
not a membership
Ethan Furman <et...@stoneleaf.us> added the comment:
issue33217 will not be "fixed" with a TypeError, but incorrect Falses are also
bad.
Rather than add __contains__ to IntFlag (and every other Flag mixin), I think
the best answer is to adjust Flag.__contains__ a little b
Ethan Furman <et...@stoneleaf.us> added the comment:
Thanks for finding this!
However, TypeError, an exception, is not the correct type of answer -- the
correct type of answer for a yes/no question is either True or False.
So the code should be changed from returning NotImple
Change by Ethan Furman <et...@stoneleaf.us>:
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
versions: +Python 3.8 -Python 3.6
___
Python tracker <rep...@bugs.python.org>
<https://bugs.pyt
Change by Ethan Furman <et...@stoneleaf.us>:
--
assignee: -> ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
versions: +Python 3.7, Python 3.8
___
Python tracker <rep...@bugs.python.org>
<https://bugs.pyt
Ethan Furman <et...@stoneleaf.us> added the comment:
Thanks for catching that!
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker <rep...@bugs.python.org>
<https://bu
Ethan Furman <et...@stoneleaf.us> added the comment:
This functionality is now in the third-party aenum* library.
Are there any strong use-cases for this behavior such that it should be in the
stdlib?
* as of version 2.0.10, available on PyPI, and I am its author
--
nosy:
Change by Ethan Furman <et...@stoneleaf.us>:
--
pull_requests: +5183
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue29237>
___
_
Ethan Furman <et...@stoneleaf.us> added the comment:
New changeset 863b1e4d0e95036bca4e97c1b8b2ca72c19790fb by Ethan Furman
(mwidjaja) in branch 'master':
bpo-29237: Create enum for pstats sorting options (GH-5103)
https://github.com/python/cpython/
Ethan Furman <et...@stoneleaf.us> added the comment:
New changeset a4b1bb4801f7a941ff9e86b96da539be1c288833 by Ethan Furman in
branch 'master':
bpo-31801: Enum: add _ignore_ as class option (#5237)
https://github.com/python/cpython/commit/a4b1bb4801f7a941ff9e86b96da539be1c
Ethan Furman <et...@stoneleaf.us> added the comment:
I'm not convinced this piece needs to be in the stdlib. Unlike other bits that
need extensive metaclass support this is trivial to add:
class DerivedEnumMeta(EnumMeta):
def __getitem__(cls, name):
try:
retu
Change by Ethan Furman <et...@stoneleaf.us>:
--
keywords: +patch
pull_requests: +5083
stage: needs patch -> patch review
___
Python tracker <rep...@bugs.python.org>
<https://bugs.pyt
Change by Ethan Furman <et...@stoneleaf.us>:
--
stage: test needed -> needs patch
___
Python tracker <rep...@bugs.python.org>
<https://bugs.pyt
Change by Ethan Furman <et...@stoneleaf.us>:
--
assignee: -> ethan.furman
stage: -> needs patch
___
Python tracker <rep...@bugs.python.org>
<https://bugs.
Ethan Furman <et...@stoneleaf.us> added the comment:
To move this forward:
The proposal is to add support for a new method, _missing_name_, which is
called by __getitem__.
If such a method does not exist, the normal AttributeError exception is raised;
otherwise, the _missing_name_
Change by Ethan Furman <et...@stoneleaf.us>:
--
Removed message: https://bugs.python.org/msg307149
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python
Ethan Furman <et...@stoneleaf.us> added the comment:
Yup, I sure did. :/
Looks like a good change to me. Are these the only instances of quotes used
with %r?
--
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python
Ethan Furman <et...@stoneleaf.us> added the comment:
I make sure to use %r in error-reporting and debugging messages precisely
because it's output is (usually) valid python. If I see a 1 without quotes I
know it's a number, and with quotes I know it's a string.
-1
-
Ethan Furman <et...@stoneleaf.us> added the comment:
We definitely need time with either DeprecationWarning or FutureWarning before
removing/substituting a function.
--
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python
Change by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31742>
___
_
Ethan Furman <et...@stoneleaf.us> added the comment:
I agree with MAL; removing functions just makes multi-version code more
painful. At least have the DeprecationWarning active for two releases before
removing it.
--
nosy: +ethan.
New submission from Ethan Furman <et...@stoneleaf.us>:
The following code should work (from
https://stackoverflow.com/a/46780742/208880):
class BaudRate(Enum):
cls = vars()
regexp = r"(?:^|,)B(?P\d+)"
rates = sorted(map(int, re.findall(regexp, &quo
Ethan Furman <et...@stoneleaf.us> added the comment:
INADA Naoki said:
> But while new instance is not created each time, 4 Python method
> calls (e,g. IntFlag.__and__() -> IntFlag.__new__()
> -> IntFlag._missing_() -> IntFlag._create_pseudo_member_())
> are much s
Ethan Furman <et...@stoneleaf.us> added the comment:
IntFlag.__and__ does not create a new instance every time -- all new instances
are cached in the IntFlag machinery (so RegexFlag(7) is only created once).
If all the RegexFlag combinations are created before the regex compile
benchm
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31085>
___
_
Ethan Furman added the comment:
New changeset 504b95047a8ada06ab630abce55ac2f85566ca37 by ethanfurman (Dong-hee
Na) in branch '3.6':
[3.6] bpo-30616: Functional API of enum allows to create empty enums. (#2304)
(#2324)
https://github.com/python/cpython/commit
Ethan Furman added the comment:
3.7 fixed, now need 3.6.
--
stage: test needed -> backport needed
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.or
Ethan Furman added the comment:
New changeset dcc8ce44c74492670e6bfbde588a2acbf8f365e0 by ethanfurman (Dong-hee
Na) in branch 'master':
bpo-30616: Functional API of enum allows to create empty enums. (#2304)
https://github.com/python/cpython/commit/dcc8ce44c74492670e6bfbde588a2acbf8f365e0
Changes by Ethan Furman <et...@stoneleaf.us>:
--
assignee: -> ethan.furman
components: +Library (Lib)
priority: normal -> low
stage: -> test needed
versions: +Python 3.7
___
Python tracker <rep...@bugs.python.org>
<http://bu
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30616>
___
_
Ethan Furman added the comment:
Marriatta, perhaps it is time to let Ratnadeep work on this issue?
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Ethan Furman added the comment:
No test code has been provided, so lacking any evidence of this problem I am
closing this issue.
Do not reopen without testable code to show the failure.
--
resolution: -> not a bug
stage: test needed -> resolved
status: open -&g
Ethan Furman added the comment:
If your example code is the same as the code in the SO problem, then my
previous points stand.
According to the plain-English description you provided the comparison would
succeed, so if you have example code which:
- doesn't involve ModuleA being the __main__
Ethan Furman added the comment:
Two points:
- Python 2.7 was the version marked, but 2.7 does not come with Enum
(wasn't introduced until 3.4 -- the third-party backport does work
on 2.7)
- the problem in the SO question is not caused by Enum, but by
re-importing a module under
Ethan Furman added the comment:
I suspect it was a simple oversight, and should be added now. Since it's been
missing for so long I think we should put it in 3.7, maybe put it in 3.6 (maybe
not, since it has two point releases out now), but definitely not in 3.5
Ethan Furman added the comment:
Have you made sure nothing calls the replaced functions manually?
Such as:
...
self._set_foo(9)
...
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Ethan Furman added the comment:
Thank you, Josh, that's a very good point.
One can be expected to have the correct spelling when using attribute access.
So the two accesses that make sense for a _missing_ call would then be:
- by-value lookup (e.g. Label(1))
- by-name lookup (e.g. Label
New submission from Ethan Furman:
class Label(Enum):
RedApple = 1
GreenApple = 2
@classmethod
def _missing_(cls, name):
for member in cls:
if member.name.lower() == name.lower():
return member
Currently, _missing_ is only called when using
Ethan Furman added the comment:
Serhiy, agreed. Closing.
Marc, thanks, I see I missed supporting non-auto() combinations. Feel free to
open an issue for that at:
https://bitbucket.org/stoneleaf/aenum
Either way I'll get that fixed.
--
resolution: -> rejected
stage: -> re
Ethan Furman added the comment:
aenum 2.0 [1] has been released. Because it also covers Python 2.7 I had to
enhance its auto() to cover |, &, ^, and ~ so that Enum classes could be
properly created.
At this moment your choices are to use odd naming or aenum (with its enhanced
auto).
Ethan Furman added the comment:
`Flag` and `IntFlag` are indeed the correct (and missing) names.
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Ethan Furman added the comment:
I also think using leading underscores is a better way to signal that a
particular value is "weird".
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.py
Ethan Furman added the comment:
@Julian: Giving flag combinations their own name can be useful. For example,
instead of seeing Color.GREEN|RED one can see Color.YELLOW .
@Marc: I'm not convinced this is a needed change as it doesn't seem to be a
common method, nor one that cannot be easily
Ethan Furman added the comment:
Possibilities:
- only allow one base Enum class
(fails with All and IntFlag)
- only allow base Enum classes that are compatible
(so not an Enum and a Flag)
(would require multiple base classes for the same behavior: DocEnum,
DocFlag, etc.)
- only allow
Ethan Furman added the comment:
While only IntColor fails with an error, Color also fails as it is not a Flag
type Enum:
>>> list(Color)
[, , ]
It should have values of 1, 2, 4.
--
___
Python tracker <rep...@bugs.pytho
Ethan Furman added the comment:
To get the above code snippet to fail properly:
- remove the @classattr line
- prepend from enum import Enum, Flag, IntFlag, auto
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
New submission from Ethan Furman:
Consider:
class AllEnum(Enum):
@classattr
def ALL(cls):
members = list(cls)
all_value = None
if members:
all_value = members[0]
for member in members[1:]:
all_value |= member
Ethan Furman added the comment:
Before talking about the patch, have you signed the Contributer License
Agreement yet? The issue tracker isn't showing that you have. Check out
https://www.python.org/psf/contrib/contrib-form/ to do so.
---
The `symlinks` flag: can you give some glob
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29446>
___
_
Ethan Furman added the comment:
Probably not because an enum class' __call__ comes from the type EnumMeta -- so
having two different __call__ methods would mean two different metaclasses, and
I'm pretty sure I don't want to go there. ;)
There is a __doc__ defined for the __call__ method
Ethan Furman added the comment:
There are actually two signatures:
EnumCls(value) --> return member with value `value`
EnumCls(name, members, module, qualname, type, start) --> create new Enum
An example of the first:
class A(Enum):
x = 1
A(1) -->
an example of the secon
Ethan Furman added the comment:
That that is very unhelpful help text. :(
Better would be:
Color(value)
So how do we allow Python code to determine the help text?
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.p
New submission from Ethan Furman:
>From issue29338, msg286139:
--
It is easy to fix the [pydoc] test by adding missed lines. But I'm not sure
that output the (correct) signature of enum classes makes the help better.
Color(value, names=None, *, module=None, qualn
Ethan Furman added the comment:
Fixed the race condition for both the RuntimeError and for getting duplicate
composite members.
--
keywords: +patch
stage: test needed -> patch review
Added file: http://bugs.python.org/file46394/issue29167.stoneleaf.01.pa
Ethan Furman added the comment:
>From Yury Selivanov:
---
This is a neat idea, but this will only work for parsing framed
binary protocols. For example, if you protocol prefixes all packets
with a length field, you can write an efficient read buffer and
use your propo
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29328>
___
_
Ethan Furman added the comment:
Any path/file attributes, etc, inside a ZipFile should be str. ZipFile should
also function properly if path/file requests are given as os.PathLike objects.
--
___
Python tracker <rep...@bugs.python.org>
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29238>
___
_
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
stage: -> needs patch
___
Python tracker <rep...@bugs.python.org>
<http://bugs.pyt
Ethan Furman added the comment:
To keep backwards compatibility and lesson the burden on new code, simply make
the value of the duplicate names be the same:
cumulative = 'cumulative'
cumtime = 'cumulative'
This way the standard name is 'cumulative' but 'cumtime' works as well
Ethan Furman added the comment:
Thanks. I'll go through and audit all my dictionary iterations.
--
nosy: +barry, eli.bendersky
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Changes by Ethan Furman <et...@stoneleaf.us>:
--
assignee: -> ethan.furman
stage: -> test needed
___
Python tracker <rep...@bugs.python.org>
<http://bugs.
Ethan Furman added the comment:
Simon, can you post the exact line of code that causes the error? It would be
useful for creating a test case and the couple things I have tried to duplicate
the error have worked fine.
--
___
Python tracker <
Ethan Furman added the comment:
Thanks Raymond and Jean-Sebastien.
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29103>
___
___
Changes by Ethan Furman <et...@stoneleaf.us>:
--
versions: -Python 3.5
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28172>
___
Ethan Furman added the comment:
Leaving `re` out of site.py is fine; the current question is whether to add
`enum` back to `re`.
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Ethan Furman added the comment:
Does this mean we can put enum back in re?
--
title: Python startup performance regression -> Python startup performance
regression due to enum in re
___
Python tracker <rep...@bugs.python.org>
<http://bug
Ethan Furman added the comment:
Ouch, that's a lot slower!
Victor, can you add the commands you are using for timing so I can work on
making enum imports faster?
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Ethan Furman added the comment:
As Serhiy was alluding to, if the incoming path is for the actual tar file and
is only passed along to Python itself then we probably don't need to worry
about os.fspath(). For names that will be interally stored, or are for
accessing internal files
Ethan Furman added the comment:
Thanks, Berker Peksag!
--
assignee: ethan.furman ->
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.or
Ethan Furman added the comment:
Berker, yes please. I just got back from vacation.
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
New submission from Ethan Furman:
Supporting pathlib was one of the requirements of removing the provisional
status. Why have you changed the type to enhancement?
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-zipfile.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: zipfile does not support pathlib
type: behavior
versions: Python 3.6
Adde
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-tarfile.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: tarfile does not support pathlib
type: behavior
versions: Python 3.6
Adde
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-lzma.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: lzma does not support pathlib
type: behavior
versions: Python 3.6
Added file
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-imghdr.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: imghdr does not support pathlib
type: behavior
versions: Python 3.6
Adde
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-gzip.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: gzip does not support pathlib
type: behavior
Added file: http://bugs.pyth
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-compileall.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: compileall does not support pathlib
type: behavior
versions: Pyth
Changes by Ethan Furman <et...@stoneleaf.us>:
--
files: open-bz2.stoneleaf.patch
keywords: patch
nosy: brett.cannon, ethan.furman
priority: normal
severity: normal
stage: patch review
status: open
title: bz2 does not support pathlib
type: behavior
versions: Python 3.6
Added file
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28172>
___
_
Ethan Furman added the comment:
The misspelling is intentional. That section is talking about what happens
when an "assert_" method is misspelled.
--
nosy: +ethan.furman, michael.foord
resolution: -> not a bug
stage: -> resolved
status
Ethan Furman added the comment:
I'll respond to the bulk of your comment later. For now let me assure you your
feedback has been invaluable.
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Ethan Furman added the comment:
Vedran:
1) Thank you for the bug report, it's appreciated.
2) I would appreciate it even more if you just kept it to a bug report
without the, for lack of a better word, drama.
---
>>>>
Ethan Furman added the comment:
__definition_order__ was dropped from PEP520, so this issue is moot.
--
resolution: -> rejected
stage: test needed -> resolved
status: open -> closed
___
Python tracker <rep...@bugs.python.org>
<http
Ethan Furman added the comment:
The PEP 467 has not been accepted yet, so nothing is final. The email thread
is the current discussion.
Also, unless someone has received permission from Ned, this won't go in until
Python 3.7.
--
___
Python
Ethan Furman added the comment:
Thanks, Ned!
--
assignee: -> ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28083>
___
___
Ethan Furman added the comment:
I did, immediately after your first post -- it's now RegexFlag. Thank you for
the suggestion! Naming things can be hard, especially when trying to beat a
deadline.
--
___
Python tracker <rep...@bugs.python.
Changes by Ethan Furman <et...@stoneleaf.us>:
--
nosy: +ethan.furman
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11957>
___
_
601 - 700 of 1854 matches
Mail list logo