]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-92049: Forbid pickling constants re._constants.SUCCESS etc (GH-92070)
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 30 Apr 2022 10:03:23 +0000 (13:03 +0300)
committerGitHub <noreply@github.com>
Sat, 30 Apr 2022 10:03:23 +0000 (13:03 +0300)
Previously, pickling did not fail, but the result could not be unpickled.

Lib/re/_constants.py
Misc/NEWS.d/next/Library/2022-04-30-10-53-10.gh-issue-92049.5SEKoh.rst [new file with mode: 0644]

index c45ce409e21b85d5aa314f5fd3f03773f8ad9e31..71204d903b3226dce2112cc2b17c9e90abf7acff 100644 (file)
@@ -62,6 +62,8 @@ class _NamedIntConstant(int):
     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 (file)
index 0000000..cad4621
--- /dev/null
@@ -0,0 +1,2 @@
+Forbid pickling constants ``re._constants.SUCCESS`` etc. Previously,
+pickling did not fail, but the result could not be unpickled.