This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients The Compiler, barry, eli.bendersky, ethan.furman, ezio.melotti, mrabarnett, rhettinger, scoder, serhiy.storchaka, veky
Date 2021-04-12.20:07:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618258062.37.0.41205695258.issue40066@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2021-04-12 20:07:42scodersetrecipients: + scoder, barry, rhettinger, ezio.melotti, mrabarnett, eli.bendersky, ethan.furman, serhiy.storchaka, The Compiler, veky
2021-04-12 20:07:42scodersetmessageid: <1618258062.37.0.41205695258.issue40066@roundup.psfhosted.org>
2021-04-12 20:07:42scoderlinkissue40066 messages
2021-04-12 20:07:42scodercreate