[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-27 Thread Łukasz Langa

Łukasz Langa  added the comment:

repr(re.RegexFlag(0)) no longer crashes so we can close this.

--
resolution:  -> fixed
stage: patch review -> 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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-25 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 24da544014f78e6f1440d5ce5c2d14794a020340 by Pablo Galindo Salgado 
in branch 'main':
bpo-44929: [Enum] Fix global repr (GH-27789)
https://github.com/python/cpython/commit/24da544014f78e6f1440d5ce5c2d14794a020340


--

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-18 Thread Ethan Furman


Ethan Furman  added the comment:

`_name_` is only None if the entire enum value is outside any named member and 
`_boundary_` is `KEEP` -- so

class Example(Flag, boundary=KEEP):
first = auto()
second = auto()
third = auto()

>>> Example(0)
module.Example(0)

>>> Example(8)
module.Example(8)

No need to backport.

--
versions:  -Python 3.10

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-18 Thread Łukasz Langa

Łukasz Langa  added the comment:

Ethan, could you take a look at the PR? I added a few failing test methods 
since `repr` handling for global enum flags wasn't covered and looks 
unfinished. If you tell us what the expected return values should be, I'll 
finish the fix.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This looks incorrect:

https://github.com/python/cpython/blob/1512bc21d60f098a9e9f37b44a2f6a9b49a3fd4f/Lib/enum.py#L1399

--

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Simpler reproducer:

>>> import re
>>> re.RegexFlag(0)
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/pablogsal/github/cpython/Lib/enum.py", line 1399, in 
global_flag_repr
return "%x" % (module, cls_name, self._value_)
   ~^~
TypeError: %x format: an integer is required, not str

--

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

(Deleted last message because it was incorrect)

--

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Same happens when printing a enum.Flag with some values:

>>> enum.Flag(1)
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/pablogsal/github/cpython/Lib/enum.py", line 597, in __call__
return cls.__new__(cls, value)
   ^^^
  File "/home/pablogsal/github/cpython/Lib/enum.py", line 944, in __new__
raise exc
^
  File "/home/pablogsal/github/cpython/Lib/enum.py", line 921, in __new__
result = cls._missing_(value)
 
  File "/home/pablogsal/github/cpython/Lib/enum.py", line 1185, in _missing_
raise ValueError(
^
ValueError: Flag: invalid value: 1
given 0b0 1
  allowed 0b0 0

--

___
Python tracker 

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



[issue44929] Some RegexFlag cannot be printed in the repr

2021-08-16 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

When printing some instance of RegexFlag **in the REPL** it fails to print:

>>> import gc
# This prints a ton of objects, including the bad enum RegexFlag one
>>> gc.get_referrers(None) 
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/pablogsal/github/cpython/Lib/enum.py", line 1399, in 
global_flag_repr
return "%x" % (module, cls_name, self._value_)
   ~^~
TypeError: %x format: an integer is required, not str

--
messages: 399688
nosy: ethan.furman, pablogsal
priority: normal
severity: normal
status: open
title: Some RegexFlag cannot be printed in the repr
versions: Python 3.10, Python 3.11

___
Python tracker 

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