New submission from Yves <[email protected]>:

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 <[email protected]>
<https://bugs.python.org/issue39687>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to