]> granicus.if.org Git - python/commitdiff
Bug #1675967: re patterns pickled with older Python versions can
authorŽiga Seilnacht <ziga.seilnacht@gmail.com>
Wed, 21 Mar 2007 20:37:39 +0000 (20:37 +0000)
committerŽiga Seilnacht <ziga.seilnacht@gmail.com>
Wed, 21 Mar 2007 20:37:39 +0000 (20:37 +0000)
now be unpickled.
 (backport form rev. 54492)

Lib/sre.py
Lib/test/test_re.py
Misc/NEWS

index 390094aaa68be78c672ffe2275875d24fa752a57..c04576bafa58871e84333c0da2a074614c01e97b 100644 (file)
@@ -8,3 +8,6 @@ warnings.warn("The sre module is deprecated, please import re.",
 
 from re import *
 from re import __all__
+
+# old pickles expect the _compile() reconstructor in this module
+from re import _compile
index 14a0acfc6bd1d6dbc2e05ac8dc7bf42702b62078..a8851804e422bb36cb195bd4da4356f6cbc9e0c4 100644 (file)
@@ -414,6 +414,15 @@ class ReTests(unittest.TestCase):
         self.pickle_test(pickle)
         import cPickle
         self.pickle_test(cPickle)
+        # old pickles expect the _compile() reconstructor in sre module
+        import warnings
+        original_filters = warnings.filters[:]
+        try:
+            warnings.filterwarnings("ignore", "The sre module is deprecated",
+                                    DeprecationWarning)
+            from sre import _compile
+        finally:
+            warnings.filters = original_filters
 
     def pickle_test(self, pickle):
         oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)')
index 19b8f1cee84c449b5f4ecc730da4d3cefdef703b..e526ac332d51933e8e4602c559e10af962794f87 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -217,6 +217,9 @@ Extension Modules
 Library
 -------
 
+- Bug #1675967: re patterns pickled with Python 2.4 and earlier can
+  now be unpickled with Python 2.5.
+
 - Bug #1684254: webbrowser now uses shlex to split any command lines
   given to get(). It also detects when you use '&' as the last argument
   and creates a BackgroundBrowser then.