Message390895
> 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(…)
<app_enums.TrickyFlag: 1>
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. |
|
Date |
User |
Action |
Args |
2021-04-12 20:07:42 | scoder | set | recipients:
+ scoder, barry, rhettinger, ezio.melotti, mrabarnett, eli.bendersky, ethan.furman, serhiy.storchaka, The Compiler, veky |
2021-04-12 20:07:42 | scoder | set | messageid: <1618258062.37.0.41205695258.issue40066@roundup.psfhosted.org> |
2021-04-12 20:07:42 | scoder | link | issue40066 messages |
2021-04-12 20:07:42 | scoder | create | |
|