New submission from Serhiy Storchaka:

Currently the re module accepts octal escapes from \400 to \777, but ignore 
highest bit.
>>> re.search(r'\542', 'abc')
<_sre.SRE_Match object; span=(1, 2), match='b'>

This behavior looks surprising and is inconsistent with the regex module which 
preserve highest bit. Such escaping is not portable across different regular 
exception engines.

I propose to add a warning when octal escape value is larger than 0o377. Here 
is preliminary patch which adds UserWarning. Or may be better to emit 
DeprecationWarning and then replace it by ValueError in future releases?

----------
components: Library (Lib), Regular Expressions
files: re_octal_escape_overflow.patch
keywords: patch
messages: 226570
nosy: ezio.melotti, mrabarnett, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Warn about octal escapes > 0o377 in re
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file36571/re_octal_escape_overflow.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22362>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to