[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-22 Thread Ethan Furman


Change by Ethan Furman :


--
status: open -> closed

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Ethan Furman


Change by Ethan Furman :


--
priority: release blocker -> normal
resolution:  -> fixed
stage: patch review -> resolved

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 62a6594e66ca955073be2f4e5a40291a39252ef3 by Ethan Furman in 
branch 'main':
bpo-40066: [Enum] fix tests (GH-30643)
https://github.com/python/cpython/commit/62a6594e66ca955073be2f4e5a40291a39252ef3


--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread STINNER Victor


STINNER Victor  added the comment:

I created https://github.com/python/core-workflow/issues/424 "Should we make 
the Docs CI mandatory on the Python main branch?".

--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +28846
pull_request: https://github.com/python/cpython/pull/30643

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Ethan Furman


Ethan Furman  added the comment:

vstinner wrote:
--
>>self.assertEqual(repr(type), '')

> For this one, I suggest to replace the value with "..." doctest pattern.

That bit of code is from the unittest suite, not the doctest suite.

I went with:  

self.assertEqual(repr(type), '' % type.value)

--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread STINNER Victor


STINNER Victor  added the comment:

>self.assertEqual(repr(type), '')

For this one, I suggest to replace the value with "..." doctest pattern.

--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 83d544b9292870eb44f6fca37df0aa351c4ef83a by Kumar Aditya in 
branch 'main':
bpo-40066: [Enum] skip failing doc test (GH-30637)
https://github.com/python/cpython/commit/83d544b9292870eb44f6fca37df0aa351c4ef83a


--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Ethan Furman


Ethan Furman  added the comment:

After merging in doc fix by kumaraditya303, I'll update tests so Solaris passes.

--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303
nosy_count: 15.0 -> 16.0
pull_requests: +28840
pull_request: https://github.com/python/cpython/pull/30637

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread STINNER Victor


STINNER Victor  added the comment:

Sorry, I had to revert the change since it broke the CI and it prevented to 
merge new PRs. Tell me if I can help to get this test fixed and to get this 
change merged again.

By the way, the PR 30582 was merged even if the Docs CI failed.

--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 42a64c03ec5c443f2a5c2ee4284622f5d1f5326c by Victor Stinner in 
branch 'main':
Revert "bpo-40066:  [Enum] update str() and format() output (GH-30582)" 
(GH-30632)
https://github.com/python/cpython/commit/42a64c03ec5c443f2a5c2ee4284622f5d1f5326c


--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner
nosy_count: 14.0 -> 15.0
pull_requests: +28835
pull_request: https://github.com/python/cpython/pull/30632

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-17 Thread Jakub Kulik


Jakub Kulik  added the comment:

This also broke our Solaris build with the following error:

==
FAIL: testGetaddrinfo (test.test_socket.GeneralModuleTests)
--
Traceback (most recent call last):
  File "//cpython-main/Lib/test/test_socket.py", line 1523, in 
testGetaddrinfo
self.assertEqual(repr(type), '')
^^^
AssertionError: '' != ''
- 
?  ^
+ 
?  ^

(test.test_socket.GeneralModuleTests fails with the same error).

The issue is almost certainly that on Solaris, SOCK_STREAM is defined as 2 
rather than 1; the following simple program confirms that:

#include 
#include 

void main() {
printf("%d\n", SOCK_STREAM);
}

I'm just not sure whether to fix this with `assertRegex` or a special branch 
for Solaris (though I am not sure whether everybody else uses 1 or it's more 
varied).

--
nosy: +kulikjak

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-16 Thread Christian Heimes


Christian Heimes  added the comment:

GH-30582 broke doc tests in 3.11 branch:

File "library/enum.rst", line ?, in default
Failed example:
Color(0)
Exception raised:
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Lib/doctest.py", line 1346, in 
__run
exec(compile(example.source, filename, "single",

  File "", line 1, in 
Color(0)
^
NameError: name 'Color' is not defined

--
nosy: +christian.heimes, pablogsal
priority: normal -> release blocker
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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-15 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset acf7403f9baea3ae1119fc6b4a3298522188bf96 by Ethan Furman in 
branch 'main':
bpo-40066:  [Enum] update str() and format() output (GH-30582)
https://github.com/python/cpython/commit/acf7403f9baea3ae1119fc6b4a3298522188bf96


--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-13 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +28780
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30582

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-06-30 Thread Michael Cuthbert


Michael Cuthbert  added the comment:

It may be helpful for the enum module to come with transitional functions like 
"pre310_str()" "pre310_repr()" "pre310_flag_str()" etc. so that people who are 
writing doctests that need to function on both < 3.10 and 3.10+ can temporarily 
do a "Enum.__str__ = pre310_str" in their test suites (and of course restore it 
later) until <=3.9 is no longer supported.  Otherwise everyone with doctest 
suites will be doing this ourselves.

--
nosy: +mscuthbert

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-04-13 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you for the feedback.  

The new str() and repr() make more sense for Flag-based enumerations, and I'm 
hesitant to have different formats for Enum- vs Flag-based enums.

Would it be helpful to have another base Enum class to derive from that 
maintained the original str() and repr() formats?

--
resolution: fixed -> 
stage: resolved -> 
status: closed -> open

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-04-13 Thread Florian Bruhin


Florian Bruhin  added the comment:

I'm probably a bit late to the party as well, but as some additional datapoints:

- This broke the tests for my project and I ended up adding a wrapper to 
stringify enums (since I actually prefer having the enum type in debug logs and 
such): 
https://github.com/qutebrowser/qutebrowser/commit/e2c5fe6262564d9d85806bfa9d4486a411cf5045
- This broke tests for pytest, and also changes its test IDs when enums are 
used for test parametrization, which might cause more breakage downstream: 
https://github.com/pytest-dev/pytest/issues/8546

--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-04-12 Thread Stefan Behnel

Stefan Behnel  added the comment:

> why /shouldn't/ we make the change?

It breaks doctests, and probably some other unit tests, too, e.g. for output 
formatting.

What should we suggest users to do? Replace

>>> get_flag(…)


by

>>> get_flag(…) == app_enums.TrickyFlag  or get_flag(…)  # (also show 
result on failure)
True

and

assertEqual(
"You caught the %s flag!" % result,
"You caught the app_enums.TrickyFlag flag!")

by

assertEqual(
("You caught the %s flag!" % result).replace("app_enums.", ""),
"You caught the TrickyFlag flag!")

?

Note that using "%r" does not help, since it's also backwards incompatible.

For their own enums, users can probably backport (or forward-port) "__str__()" 
and "__repr__()" themselves in order to work around this difference. But it's 
something they would have to do.

I certainly understand the reasoning, and it also makes new Py3.10-only 
doctests nicer, actually, but IMHO it counts as deliberate breakage.

--
nosy: +scoder

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-04-08 Thread Ethan Furman


Change by Ethan Furman :


--
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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-04-08 Thread Florian Bruhin


Change by Florian Bruhin :


--
nosy: +The Compiler

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-03-31 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +23862
pull_request: https://github.com/python/cpython/pull/25118

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-03-31 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +23861
pull_request: https://github.com/python/cpython/pull/25116

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-03-30 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset b775106d940e3d77c8af7967545bb9a5b7b162df by Ethan Furman in 
branch 'master':
bpo-40066: Enum: modify `repr()` and `str()` (GH-22392)
https://github.com/python/cpython/commit/b775106d940e3d77c8af7967545bb9a5b7b162df


--

___
Python tracker 

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



[issue40066] Enum: modify __repr__, __str__; update docs

2021-03-25 Thread Ethan Furman


Change by Ethan Furman :


--
components: +Library (Lib)
title: Enum._convert should change __repr__ and/or __str__ to use module name 
instead of class name -> Enum: modify __repr__, __str__; update docs

___
Python tracker 

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