This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Documentation on 3.6->3.7 re.escape no longer escaping "/" or ":" should be obvious
Type: enhancement Stage: resolved
Components: Documentation, Regular Expressions Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ezio.melotti, miss-islington, mrabarnett, ned.deily, rbanffy, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-09-27 17:06 by rbanffy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16442 merged python-dev, 2019-09-27 21:11
PR 16626 merged miss-islington, 2019-10-07 21:00
PR 16647 merged rbanffy, 2019-10-08 10:29
Messages (10)
msg353380 - (view) Author: Ricardo Bánffy (rbanffy) * Date: 2019-09-27 17:06
Under Python 3.6, re.escape escapes "/"

In [1]: import re

In [2]: re.escape('http://workday.com')
Out[2]: 'http\\:\\/\\/workday\\.com'

Under 3.7 and 3.8, "/" is not escaped.

In [1]: import re

In [2]: re.escape('http://workday.com')
Out[2]: 'http://workday\\.com'

Is this change deliberate? For a minor release (3.6 to 3.7) this broke some code that generated `sed` commands to run on a remote server.
msg353384 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-27 17:27
Yes, it is deliberate. "/" and ":" do not have special meaning in regular expressions and do not need escaping. re.escape() now produces more human-readable result and works faster.
msg353389 - (view) Author: Ricardo Bánffy (rbanffy) * Date: 2019-09-27 18:53
Thanks for the clarification, Serhiy. Should we update the 3.7 docs to warn others about it?
msg353390 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-27 19:26
It is already documented. There are even examples which contain "/" and ":".
msg353392 - (view) Author: Ricardo Bánffy (rbanffy) * Date: 2019-09-27 19:39
Indeed. It was easy to miss because of the joining and sorting. Being explicit on the 3.7 changes, that '!', '"', '%', "'", ',', '/', ':', ';', '<', '=', '>', '@', '`' were up to 3.6 but are no longer escaped since 3.7, would be nice.
msg354141 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-10-07 20:54
New changeset 15ae75d660befe643ed42eb2707a557cea97256c by Serhiy Storchaka (Ricardo Bánffy) in branch 'master':
bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442)
https://github.com/python/cpython/commit/15ae75d660befe643ed42eb2707a557cea97256c
msg354143 - (view) Author: miss-islington (miss-islington) Date: 2019-10-07 21:07
New changeset b731fc521cf78e53268e35777d836ca80e7ab305 by Miss Islington (bot) in branch '3.8':
bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442)
https://github.com/python/cpython/commit/b731fc521cf78e53268e35777d836ca80e7ab305
msg354221 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-10-08 16:41
New changeset 43f5c0c4d0a608c04c3978adb45117f3943203b7 by Serhiy Storchaka (Ricardo Bánffy) in branch '3.7':
[3.7] bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442) (GH-16647)
https://github.com/python/cpython/commit/43f5c0c4d0a608c04c3978adb45117f3943203b7
msg354258 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-10-09 09:07
Thank you for your contribution Ricardo!
msg354698 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-10-15 07:30
New changeset ae41f629e187e1f0cf4d62f5a7b181c64da26466 by Ned Deily (Ricardo Bánffy) in branch '3.7':
[3.7] bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442) (GH-16647)
https://github.com/python/cpython/commit/ae41f629e187e1f0cf4d62f5a7b181c64da26466
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82475
2019-10-15 07:30:25ned.deilysetnosy: + ned.deily
messages: + msg354698
2019-10-09 09:07:52serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg354258

stage: patch review -> resolved
2019-10-08 16:41:04serhiy.storchakasetmessages: + msg354221
2019-10-08 10:29:06rbanffysetpull_requests: + pull_request16230
2019-10-07 21:07:49miss-islingtonsetnosy: + miss-islington
messages: + msg354143
2019-10-07 21:00:58miss-islingtonsetpull_requests: + pull_request16212
2019-10-07 20:54:41serhiy.storchakasetmessages: + msg354141
2019-10-01 07:59:20rbanffysettitle: re.escape no longer escapes "/" or ":" -> Documentation on 3.6->3.7 re.escape no longer escaping "/" or ":" should be obvious
2019-09-30 06:53:26rbanffysetcomponents: + Regular Expressions
versions: + Python 3.9
2019-09-27 21:11:28python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16021
2019-09-27 20:00:14rbanffysetassignee: docs@python

type: behavior -> enhancement
components: + Documentation, - Regular Expressions
nosy: + docs@python
2019-09-27 19:39:52rbanffysetmessages: + msg353392
2019-09-27 19:26:14serhiy.storchakasetmessages: + msg353390
2019-09-27 18:53:57rbanffysetmessages: + msg353389
2019-09-27 17:27:26serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg353384
2019-09-27 17:08:47rbanffysettitle: re.escape seems to miss some importante regex characters -> re.escape no longer escapes "/" or ":"
2019-09-27 17:06:37rbanffycreate