Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

The-Compiler
Copy link
Contributor

sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308

This fixes a DeprecationWarning when running python3 -Wall -c "import lark" with Python 3.11.0a7.

I couldn't run the tests on Python 3.11 due to PiotrDabkowski/Js2Py#282, but it looks like at least lark works without deprecation warnings with this change.

sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308
lark/utils.py Outdated
@@ -113,8 +113,13 @@ def deserialize(cls, data, namespace, memo):
except ImportError:
regex = None

import sre_parse
import sre_constants
try: # Python 3.11
Copy link
Contributor

@henryiii henryiii May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using sys.version_info >= (3, 11) or similar instead of try on import, it serves as documentation to the user, it enables the workaround to be dropped when that version of Python is dropped, and it can be used by static analysis tools like mypy and pyupgrade.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You make a good point, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted accordingly. Also has its downsides, though (it will break now with Python 3.11 before alpha 7, and there isn't a very straightforward way to check for that).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, though older alpha / beta / rcs are not worth supporting after a new one comes out. Especially alphas once a beta is out. They are essentially just development snapshots.

Build 0.8.0 doesn’t support alpha 6 either.

@erezsh erezsh merged commit d6ad13a into lark-parser:master May 23, 2022
@erezsh
Copy link
Member

erezsh commented May 23, 2022

Thanks for contributing!

@Zac-HD
Copy link
Contributor

Zac-HD commented Sep 5, 2022

Any timeline on a release? As far as I can tell this is the last thing stopping me from testing with -Werror on Python 3.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants