[New-bugs-announce] [issue29195] Get rid of supporting outdated wrong keyword arguments in re methods

Serhiy Storchaka report at bugs.python.org
Sat Jan 7 07:04:53 EST 2017

New submission from Serhiy Storchaka:

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

components: Extension Modules
files: re_wrong_string_argument_name.patch
keywords: patch
messages: 284911
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Get rid of supporting outdated wrong keyword arguments in re methods
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file46192/re_wrong_string_argument_name.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list