Skip to content

re groups() raises OverflowError for unmatched optional groups #18877

@MyrikLD

Description

@MyrikLD

Port, board and/or hardware

unix

MicroPython version

MicroPython v1.27.0 on 2026-02-26; linux [GCC 15.2.1] version

Reproduction

import re
m = re.match(r"(.)?", "")
print(m.groups())

Expected behaviour

(None,)

Observed behaviour

Traceback (most recent call last):
  File "test.py", line 5, in <module>
  File "re.py", line 70, in groups
  File "re.py", line 70, in <genexpr>
  File "re.py", line 65, in group
OverflowError: overflow converting long int to machine word

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

Labels

buglibRelates to lib/ directory in sourceport-unix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions