[Python-checkins] r65134 - in python/trunk: Lib/test/test_locale.py Misc/NEWS Modules/_localemodule.c

georg.brandl python-checkins at python.org
Sat Jul 19 14:46:21 CEST 2008


Author: georg.brandl
Date: Sat Jul 19 14:46:12 2008
New Revision: 65134

Log:
#3303: fix crash with invalid Py_DECREF in strcoll().


Modified:
   python/trunk/Lib/test/test_locale.py
   python/trunk/Misc/NEWS
   python/trunk/Modules/_localemodule.c

Modified: python/trunk/Lib/test/test_locale.py
==============================================================================
--- python/trunk/Lib/test/test_locale.py	(original)
+++ python/trunk/Lib/test/test_locale.py	Sat Jul 19 14:46:12 2008
@@ -1,4 +1,4 @@
-from test.test_support import verbose, TestSkipped
+from test.test_support import verbose, TestSkipped, TestFailed
 import locale
 import sys
 
@@ -113,3 +113,12 @@
         teststrop('\xed\x95\xa0', 'upper', '\xed\x95\xa0')
     finally:
         locale.setlocale(locale.LC_CTYPE, oldlocale)
+
+if hasattr(locale, "strcoll"):
+    # test crasher from bug #3303
+    try:
+        locale.strcoll(u"a", None)
+    except TypeError:
+        pass
+    else:
+        raise TestFailed("TypeError not raised")

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Jul 19 14:46:12 2008
@@ -56,17 +56,20 @@
   slice(None, 10, -1).indices(10) returns (9, 9, -1) instead of (9,
   10, -1).
 
-- Issue #3219: Calling a function with repeated keyword arguments, f(a=2, a=23),
-  would not cause a syntax error.  This was a regression from 2.4 caused by the
-  switch to the new compiler.
-
-- Issue #2862: Make int and float freelist management consistent with other
-  freelists.  Changes their CompactFreeList apis into ClearFreeList apis and
-  calls them via gc.collect().
+- Issue #3219: Calling a function with repeated keyword arguments,
+  f(a=2, a=23), would not cause a syntax error.  This was a regression
+  from 2.4 caused by the switch to the new compiler.
+
+- Issue #2862: Make int and float freelist management consistent with
+  other freelists.  Changes their CompactFreeList apis into
+  ClearFreeList apis and calls them via gc.collect().
 
 Library
 -------
 
+- Issue #3303: Fix a crash in locale.strcoll() when calling it with
+  invalid arguments.
+
 - Issue #3302: Fix several crashes when calling locale's gettext functions
   with None arguments.
 
@@ -145,7 +148,6 @@
   and is now better documented. Explicit unit tests for this context manager
   have been added to test_warnings.
 
-
 Build
 -----
 

Modified: python/trunk/Modules/_localemodule.c
==============================================================================
--- python/trunk/Modules/_localemodule.c	(original)
+++ python/trunk/Modules/_localemodule.c	Sat Jul 19 14:46:12 2008
@@ -301,7 +301,9 @@
     if (!PyUnicode_Check(os2)) {
         os2 = PyUnicode_FromObject(os2);
         if (!os2) {
-            Py_DECREF(os1);
+            if (rel1) {
+                Py_DECREF(os1);
+            }
             return NULL;
         } 
         rel2 = 1;


More information about the Python-checkins mailing list