classification
Title: Get rid of supporting outdated wrong keyword arguments in re methods
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-01-07 12:04 by serhiy.storchaka, last changed 2017-03-31 16:36 by dstufft. This issue is now closed.

Files
File name Uploaded Description Edit
re_wrong_string_argument_name.patch serhiy.storchaka, 2017-01-07 12:04 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (4)
msg284911 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-07 12:04
Many re methods accepted the string parameter as a keyword argument by wrong name. This was fixed in issue20283. Wrong keyword names were still accepted, but a deprecation warning was emitted if use them. Proposed patch finishes the deprecation period (started since 3.4) and removes the support of wrong names.

Python 2.7.7, 3.3.6, 3.4-3.6:

>>> import re
>>> re.compile('.').match(pattern='a')
__main__:1: DeprecationWarning: The 'pattern' keyword parameter name is deprecated.  Use 'string' instead.
<_sre.SRE_Match object; span=(0, 1), match='a'>
>>> re.compile('.').match(string='a')
<_sre.SRE_Match object; span=(0, 1), match='a'>

Python 3.7:

>>> re.compile('.').match(pattern='a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Required argument 'string' (pos 1) not found
msg284963 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-01-08 05:19
It's too bad that "pattern" lost out to the less informative "string".

+1 for finishing the work and applying this patch.
msg285009 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-08 21:48
"pattern" is not more informative, it is just wrong. The argument of the match() method is not a pattern, it is a string with which a pattern is matched.
msg285362 - (view) Author: Roundup Robot (python-dev) Date: 2017-01-13 06:54
New changeset f8678135c042 by Serhiy Storchaka in branch 'default':
Issue #29195: Removed support of deprecated undocumented keyword arguments
https://hg.python.org/cpython/rev/f8678135c042
History
Date User Action Args
2017-03-31 16:36:15dstufftsetpull_requests: + pull_request901
2017-01-13 07:02:34serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-01-13 06:54:18python-devsetnosy: + python-dev
messages: + msg285362
2017-01-08 21:48:17serhiy.storchakasetmessages: + msg285009
2017-01-08 05:19:56rhettingersetnosy: + rhettinger
messages: + msg284963
2017-01-07 12:04:53serhiy.storchakacreate