Mailing List Archive

Possible bug in `re` module in Python 3.11?
Hi,
I would like to ask your guidance as I'm entirely sure whether the problem I'm experiencing should be posted in CPython's repo as a bug issue.
I've tried using newly released Python 3.11 interpreter in some of my projects and one of them failed to start with "RuntimeError: invalid SRE code" error.

Looking into implementation of one of the dependencies I've found out that the issue has been found out by a maintainer and fixed (https://github.com/pydicom/pydicom/issues/1658).
It looks like this particular regexp caused the `re.compile()` method to raise:

```
re.compile(
r"(?P<h>^([01][0-9]|2[0-3]))"
r"((?P<m>([0-5][0-9]))?"
r"(?(5)(?P<s>([0-5][0-9]|60))?)"
r"(?(7)(\.(?P<ms>([0-9]{1,6})?))?))$"
)
```

I've checked and this hasn't been an issue in all previous Python interpreter versions, starting from 3.6 (the oldest I've checked).
What's more the regex i correctly recognized and does not cause any issues in other regexp implementations, e.g. the online tool https://regex101.com/

Could somebody help me decide whether this is indeed a bug?

Best regards,
Piotr Waszkiewicz
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NWXOPK5C4KTIHNVXVHSNHVFADTJCIE6N/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Possible bug in `re` module in Python 3.11? [ In reply to ]
On 2022-10-26 09:17, Piotr Waszkiewicz wrote:
> Hi,
> I would like to ask your guidance as I'm entirely sure whether the problem I'm experiencing should be posted in CPython's repo as a bug issue.
> I've tried using newly released Python 3.11 interpreter in some of my projects and one of them failed to start with "RuntimeError: invalid SRE code" error.
>
> Looking into implementation of one of the dependencies I've found out that the issue has been found out by a maintainer and fixed (https://github.com/pydicom/pydicom/issues/1658).
> It looks like this particular regexp caused the `re.compile()` method to raise:
>
> ```
> re.compile(
> r"(?P<h>^([01][0-9]|2[0-3]))"
> r"((?P<m>([0-5][0-9]))?"
> r"(?(5)(?P<s>([0-5][0-9]|60))?)"
> r"(?(7)(\.(?P<ms>([0-9]{1,6})?))?))$"
> )
> ```
>
> I've checked and this hasn't been an issue in all previous Python interpreter versions, starting from 3.6 (the oldest I've checked).
> What's more the regex i correctly recognized and does not cause any issues in other regexp implementations, e.g. the online tool https://regex101.com/
>
> Could somebody help me decide whether this is indeed a bug?
>
It's definitely a bug.

If it was complaining about the pattern then it might or might not be a
bug, you'd need to check more closely, but "invalid SRE code" is
definitely a bug.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/AKNT5OED4FQ4WLETVA3TO4JL35OGXS6M/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Possible bug in `re` module in Python 3.11? [ In reply to ]
26.10.22 11:17, Piotr Waszkiewicz ????:
> Hi,
> I would like to ask your guidance as I'm entirely sure whether the problem I'm experiencing should be posted in CPython's repo as a bug issue.
> I've tried using newly released Python 3.11 interpreter in some of my projects and one of them failed to start with "RuntimeError: invalid SRE code" error.
>
> Looking into implementation of one of the dependencies I've found out that the issue has been found out by a maintainer and fixed (https://github.com/pydicom/pydicom/issues/1658).
> It looks like this particular regexp caused the `re.compile()` method to raise:
>
> ```
> re.compile(
> r"(?P<h>^([01][0-9]|2[0-3]))"
> r"((?P<m>([0-5][0-9]))?"
> r"(?(5)(?P<s>([0-5][0-9]|60))?)"
> r"(?(7)(\.(?P<ms>([0-9]{1,6})?))?))$"
> )
> ```
>
> I've checked and this hasn't been an issue in all previous Python interpreter versions, starting from 3.6 (the oldest I've checked).
> What's more the regex i correctly recognized and does not cause any issues in other regexp implementations, e.g. the online tool https://regex101.com/
>
> Could somebody help me decide whether this is indeed a bug?

Yes, it is a bug, and I have found its cause. Please open an issue on
the CPython bug tracker.



_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/GQP6P2CLVX4EOND73JYOXWNCIA3HIERW/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: Possible bug in `re` module in Python 3.11? [ In reply to ]
Thank you very much for your input, I've filled in the bug report:
https://github.com/python/cpython/issues/98740

Best regards,
Piotr

On Wed, Oct 26, 2022 at 6:55 PM Serhiy Storchaka <storchaka@gmail.com>
wrote:

> 26.10.22 11:17, Piotr Waszkiewicz ????:
> > Hi,
> > I would like to ask your guidance as I'm entirely sure whether the
> problem I'm experiencing should be posted in CPython's repo as a bug issue.
> > I've tried using newly released Python 3.11 interpreter in some of my
> projects and one of them failed to start with "RuntimeError: invalid SRE
> code" error.
> >
> > Looking into implementation of one of the dependencies I've found out
> that the issue has been found out by a maintainer and fixed (
> https://github.com/pydicom/pydicom/issues/1658).
> > It looks like this particular regexp caused the `re.compile()` method to
> raise:
> >
> > ```
> > re.compile(
> > r"(?P<h>^([01][0-9]|2[0-3]))"
> > r"((?P<m>([0-5][0-9]))?"
> > r"(?(5)(?P<s>([0-5][0-9]|60))?)"
> > r"(?(7)(\.(?P<ms>([0-9]{1,6})?))?))$"
> > )
> > ```
> >
> > I've checked and this hasn't been an issue in all previous Python
> interpreter versions, starting from 3.6 (the oldest I've checked).
> > What's more the regex i correctly recognized and does not cause any
> issues in other regexp implementations, e.g. the online tool
> https://regex101.com/
> >
> > Could somebody help me decide whether this is indeed a bug?
>
> Yes, it is a bug, and I have found its cause. Please open an issue on
> the CPython bug tracker.
>
>
>
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/GQP6P2CLVX4EOND73JYOXWNCIA3HIERW/
> Code of Conduct: http://python.org/psf/codeofconduct/
>