[pypy-svn] r69814 - pypy/trunk/pypy/module/_locale

afa at codespeak.net afa at codespeak.net
Tue Dec 1 18:11:25 CET 2009


Author: afa
Date: Tue Dec  1 18:11:24 2009
New Revision: 69814

Modified:
   pypy/trunk/pypy/module/_locale/interp_locale.py
Log:
Fix a segfault in test_locale, when run by "pypy-c test_all.py -A"
(VS 8.0 aborts the program when invalid arguments are passed)

CPython has the same issue, see http://bugs.python.org/issue7419
but it's not a reason not to fix it.


Modified: pypy/trunk/pypy/module/_locale/interp_locale.py
==============================================================================
--- pypy/trunk/pypy/module/_locale/interp_locale.py	(original)
+++ pypy/trunk/pypy/module/_locale/interp_locale.py	Tue Dec  1 18:11:24 2009
@@ -86,6 +86,8 @@
         'LC_TELEPHONE',
         'LC_MEASUREMENT',
         'LC_IDENTIFICATION',
+        'LC_MIN',
+        'LC_MAX',
         # from limits.h
         'CHAR_MAX',
         )
@@ -154,6 +156,10 @@
 def setlocale(space, category, w_locale=None):
     "(integer,string=None) -> string. Activates/queries locale processing."
 
+    if cConfig.LC_MAX is not None:
+        if not cConfig.LC_MIN <= category <= cConfig.LC_MAX:
+            raise make_error(space, "invalid locale category")
+
     if space.is_w(w_locale, space.w_None) or w_locale is None:
         result = _setlocale(rffi.cast(rffi.INT, category), None)
         if not result:



More information about the Pypy-commit mailing list