]> granicus.if.org Git - python/commitdiff
backport r73268
authorBenjamin Peterson <benjamin@python.org>
Sun, 7 Jun 2009 16:24:48 +0000 (16:24 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 7 Jun 2009 16:24:48 +0000 (16:24 +0000)
Lib/locale.py
Modules/_localemodule.c

index cb77b94d97510660229a7691a1f2506ca23381fd..879725feb94a72df85e67175b109f23bd3f96013 100644 (file)
@@ -529,10 +529,8 @@ def resetlocale(category=LC_ALL):
     """
     _setlocale(category, _build_localename(getdefaultlocale()))
 
-if sys.platform in ('win32', 'darwin', 'mac'):
+if sys.platform.startswith("win"):
     # On Win32, this will return the ANSI code page
-    # On the Mac, it should return the system encoding;
-    # it might return "ascii" instead
     def getpreferredencoding(do_setlocale = True):
         """Return the charset that the user is likely using."""
         import _locale
index bf5d58d0ac87379f28ec6a5190b2c4bfc48425bb..26aed97d8f56d90470c9bd09798bdcf56b08d811 100644 (file)
@@ -412,38 +412,6 @@ PyLocale_getdefaultlocale(PyObject* self)
 }
 #endif
 
-#if defined(__APPLE__)
-/*
-** Find out what the current script is.
-** Donated by Fredrik Lundh.
-*/
-static char *mac_getscript(void)
-{
-    CFStringEncoding enc = CFStringGetSystemEncoding();
-    static CFStringRef name = NULL;
-    /* Return the code name for the encodings for which we have codecs. */
-    switch(enc) {
-    case kCFStringEncodingMacRoman: return "mac-roman";
-    case kCFStringEncodingMacGreek: return "mac-greek";
-    case kCFStringEncodingMacCyrillic: return "mac-cyrillic";
-    case kCFStringEncodingMacTurkish: return "mac-turkish";
-    case kCFStringEncodingMacIcelandic: return "mac-icelandic";
-    /* XXX which one is mac-latin2? */
-    }
-    if (!name) {
-        /* This leaks an object. */
-        name = CFStringConvertEncodingToIANACharSetName(enc);
-    }
-    return (char *)CFStringGetCStringPtr(name, 0); 
-}
-
-static PyObject*
-PyLocale_getdefaultlocale(PyObject* self)
-{
-    return Py_BuildValue("Os", Py_None, mac_getscript());
-}
-#endif
-
 #ifdef HAVE_LANGINFO_H
 #define LANGINFO(X) {#X, X}
 static struct langinfo_constant{
@@ -689,7 +657,7 @@ static struct PyMethodDef PyLocale_Methods[] = {
    METH_VARARGS, strcoll__doc__},
   {"strxfrm", (PyCFunction) PyLocale_strxfrm, 
    METH_VARARGS, strxfrm__doc__},
-#if defined(MS_WINDOWS) || defined(__APPLE__)
+#if defined(MS_WINDOWS) 
   {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
 #endif
 #ifdef HAVE_LANGINFO_H