[pypy-svn] r69802 - in pypy/trunk/pypy/module/_locale: . test

afa at codespeak.net afa at codespeak.net
Tue Dec 1 14:53:08 CET 2009


Author: afa
Date: Tue Dec  1 14:53:07 2009
New Revision: 69802

Modified:
   pypy/trunk/pypy/module/_locale/interp_locale.py
   pypy/trunk/pypy/module/_locale/test/test_locale.py
Log:
Test and fix the _getdefaultlocale() implementation on win32.


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 14:53:07 2009
@@ -431,11 +431,11 @@
         buf_country = lltype.malloc(rffi.CCHARP.TO, BUFSIZE, flavor='raw')
 
         try:
-            if (GetLocaleInfo(LOCALE_USER_DEFAULT,
-                              LOCALE_SISO639LANGNAME,
+            if (GetLocaleInfo(cConfig.LOCALE_USER_DEFAULT,
+                              cConfig.LOCALE_SISO639LANGNAME,
                               buf_lang, BUFSIZE) and
-                GetLocaleInfo(LOCALE_USER_DEFAULT,
-                              LOCALE_SISO3166CTRYNAME,
+                GetLocaleInfo(cConfig.LOCALE_USER_DEFAULT,
+                              cConfig.LOCALE_SISO3166CTRYNAME,
                               buf_country, BUFSIZE)):
                 lang = rffi.charp2str(buf_lang)
                 country = rffi.charp2str(buf_country)
@@ -445,7 +445,8 @@
             # If we end up here, this windows version didn't know about
             # ISO639/ISO3166 names (it's probably Windows 95).  Return the
             # Windows language identifier instead (a hexadecimal number)
-            elif GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE,
+            elif GetLocaleInfo(cConfig.LOCALE_USER_DEFAULT,
+                               cConfig.LOCALE_IDEFAULTLANGUAGE,
                                buf_lang, BUFSIZE):
                 lang = rffi.charp2str(buf_lang)
                 return space.newtuple([space.wrap("0x%s" % lang),

Modified: pypy/trunk/pypy/module/_locale/test/test_locale.py
==============================================================================
--- pypy/trunk/pypy/module/_locale/test/test_locale.py	(original)
+++ pypy/trunk/pypy/module/_locale/test/test_locale.py	Tue Dec  1 14:53:07 2009
@@ -309,3 +309,14 @@
         assert _locale.bind_textdomain_codeset('/', None) == 'UTF-8'
 
         assert _locale.bind_textdomain_codeset('', '') is None
+
+    def test_getdefaultlocale(self):
+        import sys
+        if sys.platform != 'win32':
+            skip("No _getdefaultlocale() to test")
+
+        import _locale
+        lang, encoding = _locale._getdefaultlocale()
+        assert lang is None or isinstance(lang, str)
+        assert encoding.startswith('cp')
+



More information about the Pypy-commit mailing list