[Python-checkins] bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442)

Miss Islington (bot) webhook-mailer at python.org
Mon Oct 7 17:07:50 EDT 2019


https://github.com/python/cpython/commit/b731fc521cf78e53268e35777d836ca80e7ab305
commit: b731fc521cf78e53268e35777d836ca80e7ab305
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-10-07T14:07:46-07:00
summary:

bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442)


Prior to 3.7, re.escape escaped many characters that don't have
special meaning in Python, but that use to require escaping in other
tools and languages. This commit aims to make it clear which characters
were, but are no longer escaped.
(cherry picked from commit 15ae75d660befe643ed42eb2707a557cea97256c)

Co-authored-by: Ricardo Bánffy <rbanffy at gmail.com>

files:
A Misc/NEWS.d/next/Documentation/2019-09-27-23-37-41.bpo-38294.go_jFf.rst
M Doc/library/re.rst
M Doc/tools/susp-ignored.csv

diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index df29c4d390908..7c950bfd5b1fd 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -931,8 +931,8 @@ form.
    This is useful if you want to match an arbitrary literal string that may
    have regular expression metacharacters in it.  For example::
 
-      >>> print(re.escape('python.exe'))
-      python\.exe
+      >>> print(re.escape('http://www.python.org'))
+      http://www\.python\.org
 
       >>> legal_chars = string.ascii_lowercase + string.digits + "!#$%&'*+-.^_`|~:"
       >>> print('[%s]+' % re.escape(legal_chars))
@@ -955,7 +955,9 @@ form.
 
    .. versionchanged:: 3.7
       Only characters that can have special meaning in a regular expression
-      are escaped.
+      are escaped. As a result, ``'!'``, ``'"'``, ``'%'``, ``"'"``, ``','``,
+      ``'/'``, ``':'``, ``';'``, ``'<'``, ``'='``, ``'>'``, ``'@'``, and
+      ``"`"`` are no longer escaped.
 
 
 .. function:: purge()
diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv
index 1f0cf3fd6ed44..a0fc874829f5f 100644
--- a/Doc/tools/susp-ignored.csv
+++ b/Doc/tools/susp-ignored.csv
@@ -354,3 +354,4 @@ whatsnew/changelog,,::,default::BytesWarning
 whatsnew/changelog,,::,default::DeprecationWarning
 library/importlib.metadata,,:main,"EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')"
 library/importlib.metadata,,`,loading the metadata for packages for the indicated ``context``.
+library/re,,`,"`"
diff --git a/Misc/NEWS.d/next/Documentation/2019-09-27-23-37-41.bpo-38294.go_jFf.rst b/Misc/NEWS.d/next/Documentation/2019-09-27-23-37-41.bpo-38294.go_jFf.rst
new file mode 100644
index 0000000000000..0bde8c868c9ec
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2019-09-27-23-37-41.bpo-38294.go_jFf.rst
@@ -0,0 +1 @@
+Add list of no-longer-escaped chars to re.escape documentation
\ No newline at end of file



More information about the Python-checkins mailing list