From 9794fd781711d3d08ec13b53ff2c42f6cbea61d0 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 30 Apr 2022 15:33:39 +0300 Subject: [PATCH] [3.9] [3.10] gh-92049: Forbid pickling constants re._constants.SUCCESS etc (GH-92070) (GH-92073) Previously, pickling did not fail, but the result could not be unpickled. (cherry picked from commit 6d0d547033e295f91f05030322acfbb0e280fc1f) (cherry picked from commit e8ff3c92f69b475aa20ba7c08efccbc329f9b42e) Co-authored-by: Serhiy Storchaka --- Lib/sre_constants.py | 2 ++ .../next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py index 8e613cb3fa5dcb..db3ca51e8306ad 100644 --- a/Lib/sre_constants.py +++ b/Lib/sre_constants.py @@ -62,6 +62,8 @@ def __new__(cls, value, name): def __repr__(self): return self.name + __reduce__ = None + MAXREPEAT = _NamedIntConstant(MAXREPEAT, 'MAXREPEAT') def _makecodes(names): diff --git a/Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst b/Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst new file mode 100644 index 00000000000000..cad4621c65096c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst @@ -0,0 +1,2 @@ +Forbid pickling constants ``re._constants.SUCCESS`` etc. Previously, +pickling did not fail, but the result could not be unpickled.