[New-bugs-announce] [issue32603] Deprecation warning on strings used in re module

Cheryl Sabella report at bugs.python.org
Fri Jan 19 18:20:51 EST 2018


New submission from Cheryl Sabella <chekat2 at gmail.com>:

I apologize if this is a duplicate question, but I couldn't find another issue about this.  It's hard to search on 're'.

In 3.7, I get a deprecation warning when using a regular string with re escape characters:
>>> s = '123abcd'
>>> re.findall('\d', s)
<stdin>:1: DeprecationWarning: invalid escape sequence \d
['1', '2', '3']

Of course, this works:
>>> s = '123abcd'
>>> re.findall(r'\d', s)
['1', '2', '3']


I know that the documentation strongly suggests using raw strings with re, but I didn't see anywhere mentioning that it would be a requirement.  I would think this would break a lot of 're' code.

----------
assignee: docs at python
components: Documentation
messages: 310300
nosy: csabella, docs at python
priority: normal
severity: normal
status: open
title: Deprecation warning on strings used in re module
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32603>
_______________________________________


More information about the New-bugs-announce mailing list