New submission from Philip <probi...@protonmail.com>:

I am receiving an unexpected behavior in using regular expressions for 
splitting a string. It seems like this error exists in `python 3.6` but not 
`python 2.7` and not `python 3.7+`. Below I have described a minimal example 
with `tox`.

`setup.py`
```
from setuptools import setup
setup(
    name='my-tox-tested-package',
    version='0.0.1',
    install_requires=["pytest"]
)
```

`tests/test_re.py`
```
import re
import pytest

_DIGIT_BOUNDARY_RE = re.compile(
    r'(?<=\D)(?=\d)|(?<=\d)(?=\D)'
)

def test():
    _DIGIT_BOUNDARY_RE.split("10.0.0")
```

`tox.ini`
```
[tox]
envlist = py27, py36, py37
requires=
  pytest

[testenv]
commands =
    pytest {posargs: tests}
```
```
============================================= FAILURES 
================================
_____________________________________________ test 
____________________________________

    def test():
>       _DIGIT_BOUNDARY_RE.split("10.0.0")
E       ValueError: split() requires a non-empty pattern match.

tests/test_god.py:9: ValueError
============================================ short test summary info 
==================
...

============================================ test session starts 
======================
platform linux -- Python 3.7.5, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/probinson/code
collected 1 item

tests/test_re.py .                                                              
  [100%]

============================================ 1 passed in 0.00s 
=========================
____________________________________________ summary 
___________________________________
  py27: commands succeeded
ERROR:   py36: commands failed
  py37: commands succeeded

```

----------
components: Regular Expressions
messages: 386942
nosy: ezio.melotti, mrabarnett, probinso
priority: normal
severity: normal
status: open
title: Regular expression split fails on 3.6 and not 2.7 or 3.7+
type: crash
versions: Python 3.6

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

Reply via email to