Skip to content

AttributeError when copying flags in the re module. #93820

Description

@pschanely

Bug report

In CPython 3.11, I've noticed that an attempt to copy (combined) regular expression flags fails with an attribute error; like so:

>>> import copy, re
>>> copy.copy(re.A | re.I)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/python3.11/copy.py", line 102, in copy
    return _reconstruct(x, None, *rv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/copy.py", line 265, in _reconstruct
    y = func(*args)
        ^^^^^^^^^^^
  File "lib/python3.11/enum.py", line 862, in __getattr__
    raise AttributeError(name) from None
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: ASCII|IGNORECASE

Your environment

  • CPython versions tested on: 3.11.0b3
  • Operating system and architecture: macOS 10.15.7

Background

This behavior was detected from a CrossHair test failure here, in which we realize possibly symbolic arguments prior to regex compilation. (it's an esoteric use case, and I expect not very high priority)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions