[New-bugs-announce] [issue39687] re.sub behaves inconsistent between versions with * repetition qualifier

Yves report at bugs.python.org
Wed Feb 19 06:40:24 EST 2020


New submission from Yves <uves at spline.de>:

On different platforms and versions the following expression has different results:

  python -c 'import re; print(re.compile("(.*)", 0).sub("a\\1", "bc"))'

As far is I observed:

  Linux/Python 3.6.9   => abc
  MacOS/Python 3.7.1   => abca
  Repl.it/Python 3.8.1 => abca
  MacOS/Python 2.7.17  => abc
  Linux/Python 2.7.17  => abc

According the the documentation I would guess that "abc" is the correct return value.

The issues also occurs without compiling or capture group:

 re.sub(".*", "a", "cb")  a vs aa

----------
components: Regular Expressions
messages: 362264
nosy: ezio.melotti, mrabarnett, slomo
priority: normal
severity: normal
status: open
title: re.sub behaves inconsistent between versions with * repetition qualifier
versions: Python 3.8

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


More information about the New-bugs-announce mailing list