mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Merged revisions 75537,75539 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r75537 | antoine.pitrou | 2009-10-19 21:37:25 +0200 (lun., 19 oct. 2009) | 3 lines egreen is Derk Drukker + fix NEWS formatting ........ r75539 | antoine.pitrou | 2009-10-19 21:43:09 +0200 (lun., 19 oct. 2009) | 4 lines Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows platforms, and assorted locale fixes by Derk Drukker. ........
This commit is contained in:
		
							parent
							
								
									bc740a6951
								
							
						
					
					
						commit
						eda95e9db3
					
				
					 6 changed files with 54 additions and 14 deletions
				
			
		| 
						 | 
					@ -575,14 +575,13 @@ def getpreferredencoding(do_setlocale = True):
 | 
				
			||||||
                    # returning nothing will crash the
 | 
					                    # returning nothing will crash the
 | 
				
			||||||
                    # interpreter.
 | 
					                    # interpreter.
 | 
				
			||||||
                    result = 'UTF-8'
 | 
					                    result = 'UTF-8'
 | 
				
			||||||
 | 
					 | 
				
			||||||
                setlocale(LC_CTYPE, oldloc)
 | 
					                setlocale(LC_CTYPE, oldloc)
 | 
				
			||||||
                return result
 | 
					 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                result = nl_langinfo(CODESET)
 | 
					                result = nl_langinfo(CODESET)
 | 
				
			||||||
                if not result and sys.platform == 'darwin':
 | 
					                if not result and sys.platform == 'darwin':
 | 
				
			||||||
                    # See above for explanation
 | 
					                    # See above for explanation
 | 
				
			||||||
                    result = 'UTF-8'
 | 
					                    result = 'UTF-8'
 | 
				
			||||||
 | 
					            return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Database
 | 
					### Database
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_enUS_locale():
 | 
					def get_enUS_locale():
 | 
				
			||||||
    global enUS_locale
 | 
					    global enUS_locale
 | 
				
			||||||
    if sys.platform == 'darwin':
 | 
					 | 
				
			||||||
        raise unittest.SkipTest("Locale support on MacOSX is minimal")
 | 
					 | 
				
			||||||
    if sys.platform.startswith("win"):
 | 
					    if sys.platform.startswith("win"):
 | 
				
			||||||
        tlocs = ("En", "English")
 | 
					        tlocs = ("En", "English")
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US")
 | 
					        tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US.US-ASCII", "en_US")
 | 
				
			||||||
    oldlocale = locale.setlocale(locale.LC_NUMERIC)
 | 
					    oldlocale = locale.setlocale(locale.LC_NUMERIC)
 | 
				
			||||||
    for tloc in tlocs:
 | 
					    for tloc in tlocs:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
| 
						 | 
					@ -309,6 +307,39 @@ def test_currency(self):
 | 
				
			||||||
            grouping=True, international=True)
 | 
					            grouping=True, international=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TestCollation(unittest.TestCase):
 | 
				
			||||||
 | 
					    # Test string collation functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_strcoll(self):
 | 
				
			||||||
 | 
					        self.assertLess(locale.strcoll('a', 'b'), 0)
 | 
				
			||||||
 | 
					        self.assertEqual(locale.strcoll('a', 'a'), 0)
 | 
				
			||||||
 | 
					        self.assertGreater(locale.strcoll('b', 'a'), 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_strxfrm(self):
 | 
				
			||||||
 | 
					        self.assertLess(locale.strxfrm('a'), locale.strxfrm('b'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TestEnUSCollation(BaseLocalizedTest, TestCollation):
 | 
				
			||||||
 | 
					    # Test string collation functions with a real English locale
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    locale_type = locale.LC_ALL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def setUp(self):
 | 
				
			||||||
 | 
					        BaseLocalizedTest.setUp(self)
 | 
				
			||||||
 | 
					        enc = codecs.lookup(locale.getpreferredencoding(False) or 'ascii').name
 | 
				
			||||||
 | 
					        if enc not in ('utf-8', 'iso8859-1', 'cp1252'):
 | 
				
			||||||
 | 
					            raise unittest.SkipTest('encoding not suitable')
 | 
				
			||||||
 | 
					        if enc != 'iso8859-1' and (sys.platform == 'darwin' or
 | 
				
			||||||
 | 
					                                   sys.platform.startswith('freebsd')):
 | 
				
			||||||
 | 
					            raise unittest.SkipTest('wcscoll/wcsxfrm have known bugs')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_strcoll_with_diacritic(self):
 | 
				
			||||||
 | 
					        self.assertLess(locale.strcoll('à', 'b'), 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_strxfrm_with_diacritic(self):
 | 
				
			||||||
 | 
					        self.assertLess(locale.strxfrm('à'), locale.strxfrm('b'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestMiscellaneous(unittest.TestCase):
 | 
					class TestMiscellaneous(unittest.TestCase):
 | 
				
			||||||
    def test_getpreferredencoding(self):
 | 
					    def test_getpreferredencoding(self):
 | 
				
			||||||
        # Invoke getpreferredencoding to make sure it does not cause exceptions.
 | 
					        # Invoke getpreferredencoding to make sure it does not cause exceptions.
 | 
				
			||||||
| 
						 | 
					@ -317,11 +348,10 @@ def test_getpreferredencoding(self):
 | 
				
			||||||
            # If encoding non-empty, make sure it is valid
 | 
					            # If encoding non-empty, make sure it is valid
 | 
				
			||||||
            codecs.lookup(enc)
 | 
					            codecs.lookup(enc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if hasattr(locale, "strcoll"):
 | 
					    def test_strcoll_3303(self):
 | 
				
			||||||
        def test_strcoll_3303(self):
 | 
					        # test crasher from bug #3303
 | 
				
			||||||
            # test crasher from bug #3303
 | 
					        self.assertRaises(TypeError, locale.strcoll, "a", None)
 | 
				
			||||||
            self.assertRaises(TypeError, locale.strcoll, "a", None)
 | 
					        self.assertRaises(TypeError, locale.strcoll, b"a", None)
 | 
				
			||||||
            self.assertRaises(TypeError, locale.strcoll, b"a", None)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_main():
 | 
					def test_main():
 | 
				
			||||||
| 
						 | 
					@ -331,6 +361,7 @@ def test_main():
 | 
				
			||||||
        TestEnUSNumberFormatting,
 | 
					        TestEnUSNumberFormatting,
 | 
				
			||||||
        TestCNumberFormatting,
 | 
					        TestCNumberFormatting,
 | 
				
			||||||
        TestFrFRNumberFormatting,
 | 
					        TestFrFRNumberFormatting,
 | 
				
			||||||
 | 
					        TestCollation
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
    # SkipTest can't be raised inside unittests, handle it manually instead
 | 
					    # SkipTest can't be raised inside unittests, handle it manually instead
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
| 
						 | 
					@ -339,7 +370,7 @@ def test_main():
 | 
				
			||||||
        if verbose:
 | 
					        if verbose:
 | 
				
			||||||
            print("Some tests will be disabled: %s" % e)
 | 
					            print("Some tests will be disabled: %s" % e)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        tests += [TestNumberFormatting]
 | 
					        tests += [TestNumberFormatting, TestEnUSCollation]
 | 
				
			||||||
    run_unittest(*tests)
 | 
					    run_unittest(*tests)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,6 +184,7 @@ Ismail Donmez
 | 
				
			||||||
Dima Dorfman
 | 
					Dima Dorfman
 | 
				
			||||||
Cesar Douady
 | 
					Cesar Douady
 | 
				
			||||||
Dean Draayer
 | 
					Dean Draayer
 | 
				
			||||||
 | 
					Derk Drukker
 | 
				
			||||||
John DuBois
 | 
					John DuBois
 | 
				
			||||||
Paul Dubois
 | 
					Paul Dubois
 | 
				
			||||||
Graham Dumpleton
 | 
					Graham Dumpleton
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ Core and Builtins
 | 
				
			||||||
-----------------
 | 
					-----------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when
 | 
					- Issue #7065: Fix a crash in bytes.maketrans and bytearray.maketrans when
 | 
				
			||||||
  using byte values greater than 127.  Patch by egreen.
 | 
					  using byte values greater than 127.  Patch by Derk Drukker.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #7019: Raise ValueError when unmarshalling bad long data, instead
 | 
					- Issue #7019: Raise ValueError when unmarshalling bad long data, instead
 | 
				
			||||||
  of producing internally inconsistent Python longs.
 | 
					  of producing internally inconsistent Python longs.
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,9 @@ Core and Builtins
 | 
				
			||||||
Library
 | 
					Library
 | 
				
			||||||
-------
 | 
					-------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Issue #7080: locale.strxfrm() raises a MemoryError on 64-bit non-Windows
 | 
				
			||||||
 | 
					  platforms, and assorted locale fixes by Derk Drukker.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #5833: Fix extra space character in readline completion with the
 | 
					- Issue #5833: Fix extra space character in readline completion with the
 | 
				
			||||||
  GNU readline library version 6.0.
 | 
					  GNU readline library version 6.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +48,7 @@ Library
 | 
				
			||||||
  is too large to fit in the current precision.
 | 
					  is too large to fit in the current precision.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #6236, #6348: Fix various failures in the I/O library under AIX
 | 
					- Issue #6236, #6348: Fix various failures in the I/O library under AIX
 | 
				
			||||||
  and other platforms, when using a non-gcc compiler. Patch by egreen.
 | 
					  and other platforms, when using a non-gcc compiler. Patch by Derk Drukker.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
 | 
					- Issue #6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ This software comes with no warranty. Use at your own risk.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
******************************************************************/
 | 
					******************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define PY_SSIZE_T_CLEAN
 | 
				
			||||||
#include "Python.h"
 | 
					#include "Python.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
| 
						 | 
					@ -315,7 +316,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
 | 
				
			||||||
    result = PyUnicode_FromWideChar(buf, n2);
 | 
					    result = PyUnicode_FromWideChar(buf, n2);
 | 
				
			||||||
 exit:
 | 
					 exit:
 | 
				
			||||||
    if (buf) PyMem_Free(buf);
 | 
					    if (buf) PyMem_Free(buf);
 | 
				
			||||||
#ifdef HAVE_USABLE_WCHAR_T
 | 
					#ifndef HAVE_USABLE_WCHAR_T
 | 
				
			||||||
    PyMem_Free(s);
 | 
					    PyMem_Free(s);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -647,6 +647,11 @@ Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
 | 
				
			||||||
#define HAVE_WCSCOLL 1
 | 
					#define HAVE_WCSCOLL 1
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `wcsxfrm' function. */
 | 
				
			||||||
 | 
					#ifndef MS_WINCE
 | 
				
			||||||
 | 
					#define HAVE_WCSXFRM 1
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Define if you have the <dlfcn.h> header file.  */
 | 
					/* Define if you have the <dlfcn.h> header file.  */
 | 
				
			||||||
/* #undef HAVE_DLFCN_H */
 | 
					/* #undef HAVE_DLFCN_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue