neo4j / neo4j-python-driver

Neo4j Bolt driver for Python
https://neo4j.com/docs/api/python-driver/current/
Other
893 stars 187 forks source link

Fix unasync script for Python 3.12 #1005

Closed robsdedude closed 8 months ago

robsdedude commented 8 months ago

Python 3.12 changed how f-strings are handled and what they're capable of. It's likely because of this reason that the tokenizer module changed how it handles f-strings as well.

When finding escaped curly brackets in an f-string (e.g., f"{{") the tokenizer will only emit a single curly bracket and pretend the token ended one symbol earlier than the pair of brackets does. This PR basically hot-fixes those tokens to behave in a more consitent way by not swallowing the seconds bracket and by re-writing the token to end where the bracket pair actually ends.