]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#13054: sys.maxunicode is now always 0x10FFFF.
authorEzio Melotti <ezio.melotti@gmail.com>
Wed, 28 Sep 2011 21:18:19 +0000 (00:18 +0300)
committerEzio Melotti <ezio.melotti@gmail.com>
Wed, 28 Sep 2011 21:18:19 +0000 (00:18 +0300)
Doc/library/sys.rst
Doc/whatsnew/3.3.rst
Lib/test/test_sys.py
Objects/unicodeobject.c
Python/sysmodule.c

index acdde6d62a1c93fbe2f9a0502c880b9400f66d6b..43f65e206b884200af9b9746172cec44c9c379fd 100644 (file)
@@ -625,9 +625,13 @@ always available.
 
 .. data:: maxunicode
 
-   An integer giving the largest supported code point for a Unicode character.  The
-   value of this depends on the configuration option that specifies whether Unicode
-   characters are stored as UCS-2 or UCS-4.
+   An integer giving the value of the largest Unicode code point,
+   i.e. ``1114111`` (``0x10FFFF`` in hexadecimal).
+
+   .. versionchanged:: 3.3
+      Before :pep:`393`, :data:`sys.maxunicode` used to return either ``0xFFFF``
+      or ``0x10FFFF``, depending on the configuration option that specified
+      whether Unicode characters were stored as UCS-2 or UCS-4.
 
 
 .. data:: meta_path
index 717e4e4748df408fd7c062f6635bdcc1f234c6c2..3cd4dd1f8250a193bb7136b32606b8a3c9cdf6f5 100644 (file)
@@ -55,6 +55,17 @@ PEP XXX: Stub
 =============
 
 
+PEP 393: Flexible String Representation
+=======================================
+
+XXX Add list of changes introduced by :pep:`393` here:
+
+* The value of :data:`sys.maxunicode` is now always ``1114111`` (``0x10FFFF``
+  in hexadecimal).  The :c:func:`PyUnicode_GetMax` function still returns
+  either ``0xFFFF`` or ``0x10FFFF`` for backward compatibility, and it should
+  not be used with the new Unicode API (see :issue:`13054`).
+
+
 Other Language Changes
 ======================
 
index 0b7bbf129661b65a8dfe7870d917f564e9bbe510..c99f4d7e092b43c8cc7609a66e6457e1feab28ae 100644 (file)
@@ -447,6 +447,7 @@ class SysModuleTest(unittest.TestCase):
 
         self.assertIsInstance(sys.maxsize, int)
         self.assertIsInstance(sys.maxunicode, int)
+        self.assertEqual(sys.maxunicode, 0x10FFFF)
         self.assertIsInstance(sys.platform, str)
         self.assertIsInstance(sys.prefix, str)
         self.assertIsInstance(sys.version, str)
index b61f0581b3204e173b79150528eacb5687d8d0b3..45d56f7f187c78fd01ecc1fe1dcce1e8eb4abc65 100644 (file)
@@ -207,7 +207,8 @@ static unsigned char ascii_linebreak[] = {
     0, 0, 0, 0, 0, 0, 0, 0
 };
 
-
+/* The max unicode value is always 0x10FFFF while using the PEP-393 API.
+   This function is kept for backward compatibility with the old API. */
 Py_UNICODE
 PyUnicode_GetMax(void)
 {
index b5492035365a3b32d9cbe2c680f583b029669dc4..dea21490e29bfb427a2a14bb16f32b177ba2be78 100644 (file)
@@ -1261,7 +1261,7 @@ float_repr_style -- string indicating the style of repr() output for floats\n\
 hexversion -- version information encoded as a single integer\n\
 int_info -- a struct sequence with information about the int implementation.\n\
 maxsize -- the largest supported length of containers.\n\
-maxunicode -- the largest supported character\n\
+maxunicode -- the value of the largest Unicode codepoint\n\
 platform -- platform identifier\n\
 prefix -- prefix used to find the Python library\n\
 thread_info -- a struct sequence with information about the thread implementation.\n\
@@ -1536,7 +1536,7 @@ _PySys_Init(void)
     SET_SYS_FROM_STRING("hash_info",
                         get_hash_info());
     SET_SYS_FROM_STRING("maxunicode",
-                        PyLong_FromLong(PyUnicode_GetMax()));
+                        PyLong_FromLong(0x10FFFF));
     SET_SYS_FROM_STRING("builtin_module_names",
                         list_builtin_module_names());
     {