[Python-checkins] cpython: #13054: sys.maxunicode is now always 0x10FFFF.

ezio.melotti python-checkins at python.org
Wed Sep 28 23:18:33 CEST 2011


http://hg.python.org/cpython/rev/606652491366
changeset:   72503:606652491366
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Thu Sep 29 00:18:19 2011 +0300
summary:
  #13054: sys.maxunicode is now always 0x10FFFF.

files:
  Doc/library/sys.rst     |  10 +++++++---
  Doc/whatsnew/3.3.rst    |  11 +++++++++++
  Lib/test/test_sys.py    |   1 +
  Objects/unicodeobject.c |   3 ++-
  Python/sysmodule.c      |   4 ++--
  5 files changed, 23 insertions(+), 6 deletions(-)


diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -625,9 +625,13 @@
 
 .. 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
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -55,6 +55,17 @@
 =============
 
 
+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
 ======================
 
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -447,6 +447,7 @@
 
         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)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -207,7 +207,8 @@
     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)
 {
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1261,7 +1261,7 @@
 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 @@
     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());
     {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list