[Python-3000-checkins] r62568 - in python/branches/py3k: Doc/reference/lexical_analysis.rst Doc/whatsnew/3.0.rst Misc/NEWS

benjamin.peterson python-3000-checkins at python.org
Mon Apr 28 23:05:10 CEST 2008


Author: benjamin.peterson
Date: Mon Apr 28 23:05:10 2008
New Revision: 62568

Log:
Document the fact that '\U' and '\u' escapes are not treated specially in 3.0 (see issue 2541)


Modified:
   python/branches/py3k/Doc/reference/lexical_analysis.rst
   python/branches/py3k/Doc/whatsnew/3.0.rst
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/reference/lexical_analysis.rst
==============================================================================
--- python/branches/py3k/Doc/reference/lexical_analysis.rst	(original)
+++ python/branches/py3k/Doc/reference/lexical_analysis.rst	Mon Apr 28 23:05:10 2008
@@ -423,8 +423,9 @@
 itself, or the quote character.
 
 String literals may optionally be prefixed with a letter ``'r'`` or ``'R'``;
-such strings are called :dfn:`raw strings` and use different rules for
-interpreting backslash escape sequences.
+such strings are called :dfn:`raw strings` and treat backslashes as literal
+characters.  As a result, ``'\U'`` and ``'\u'`` escapes in raw strings are not
+treated specially.
 
 Bytes literals are always prefixed with ``'b'`` or ``'B'``; they produce an
 instance of the :class:`bytes` type instead of the :class:`str` type.  They
@@ -520,15 +521,6 @@
 escape sequences only recognized in string literals fall into the category of
 unrecognized escapes for bytes literals.
 
-When an ``'r'`` or ``'R'`` prefix is used in a string literal, then the
-``\uXXXX`` and ``\UXXXXXXXX`` escape sequences are processed while *all other
-backslashes are left in the string*. For example, the string literal
-``r"\u0062\n"`` consists of three Unicode characters: 'LATIN SMALL LETTER B',
-'REVERSE SOLIDUS', and 'LATIN SMALL LETTER N'. Backslashes can be escaped with a
-preceding backslash; however, both remain in the string.  As a result,
-``\uXXXX`` escape sequences are only recognized when there is an odd number of
-backslashes.
-
 Even in a raw string, string quotes can be escaped with a backslash, but the
 backslash remains in the string; for example, ``r"\""`` is a valid string
 literal consisting of two characters: a backslash and a double quote; ``r"\"``

Modified: python/branches/py3k/Doc/whatsnew/3.0.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/3.0.rst	(original)
+++ python/branches/py3k/Doc/whatsnew/3.0.rst	Mon Apr 28 23:05:10 2008
@@ -167,6 +167,9 @@
   explicitly convert between them, using the :meth:`str.encode` (str -> bytes)
   or :meth:`bytes.decode` (bytes -> str) methods.
 
+* All backslashes in raw strings are interpreted literally.  This means that
+  Unicode escapes are not treated specially.
+
 .. XXX add bytearray
 
 * PEP 3112: Bytes literals, e.g. ``b"abc"``, create :class:`bytes` instances.
@@ -183,6 +186,8 @@
 * The :mod:`StringIO` and :mod:`cStringIO` modules are gone.  Instead, import
   :class:`io.StringIO` or :class:`io.BytesIO`.
 
+* ``'\U'`` and ``'\u'`` escapes in raw strings are not treated specially.
+
 
 PEP 3101: A New Approach to String Formatting
 =============================================

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon Apr 28 23:05:10 2008
@@ -26,6 +26,9 @@
   through as unmodified as possible; as a consequence, the C API
   related to command line arguments was changed to use wchar_t.
 
+- All backslashes in raw strings are interpreted literally.  This means that
+  '\u' and '\U' escapes are not treated specially.
+
 Extension Modules
 -----------------
 


More information about the Python-3000-checkins mailing list