The split() function of Python's built-in module has changed in a puzzling way - is this a bug?

Andy AO zen96285 at gmail.com
Thu Apr 22 19:53:05 EDT 2021


Upgrading from Python 3.6.8 to Python 3.9.0 and executing unit tests
revealed a significant change in the behavior of re.split().

but looking at the relevant documentation — Changelog <https://docs.
python.org/3/whatsnew/changelog.html> and re - Regular expression
operations - Python 3.9.4 documentation
<https://docs.python.org/3/library/re.html?highlight=re%20search#re.split>
yet no change is found.

number = '123'def test_Asterisk_quantifier_with_capture_group(self):
    resultList = re.split(r'(\d*)', self.number)
    if platform.python_version() == '3.6.8':
        self.assertEqual(resultList,['', '123', ''])

    else:
        self.assertEqual(resultList,['', '123', '', '', ''])

I feel that this is clearly not in line with the description of the
function in the split documentation, and it is also strange that after
replacing * with +, the behavior is still the same as in 3.6.8.

   1. why is this change not in the documentation? Is it because I didn’t
   find it?
   2. Why did the behavior change this way? Was a bug introduced, or was it
   a bug fix?


More information about the Python-list mailing list