[Python-checkins] r54497 - in python/branches/release25-maint: Lib/sre.py Lib/test/test_re.py Misc/NEWS

ziga.seilnacht python-checkins at python.org
Wed Mar 21 21:37:43 CET 2007


Author: ziga.seilnacht
Date: Wed Mar 21 21:37:39 2007
New Revision: 54497

Modified:
   python/branches/release25-maint/Lib/sre.py
   python/branches/release25-maint/Lib/test/test_re.py
   python/branches/release25-maint/Misc/NEWS
Log:
Bug #1675967: re patterns pickled with older Python versions can
now be unpickled.
 (backport form rev. 54492)

Modified: python/branches/release25-maint/Lib/sre.py
==============================================================================
--- python/branches/release25-maint/Lib/sre.py	(original)
+++ python/branches/release25-maint/Lib/sre.py	Wed Mar 21 21:37:39 2007
@@ -8,3 +8,6 @@
 
 from re import *
 from re import __all__
+
+# old pickles expect the _compile() reconstructor in this module
+from re import _compile

Modified: python/branches/release25-maint/Lib/test/test_re.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_re.py	(original)
+++ python/branches/release25-maint/Lib/test/test_re.py	Wed Mar 21 21:37:39 2007
@@ -414,6 +414,15 @@
         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)+?(.)')

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Wed Mar 21 21:37:39 2007
@@ -217,6 +217,9 @@
 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.


More information about the Python-checkins mailing list