You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SyntaxWarning: invalid escape sequence '\s' in Python 3.12+ #2268
Describe the bug
The apache-age-python library triggers warnings in Python 3.6+ due to invalid escape sequences in regex patterns. In Python 3.12+, this was upgraded from a DeprecationWarning to a SyntaxWarning, and will become a hard error (SyntaxError) in Python 3.14+.
How are you accessing AGE (Command line, driver, etc.)?
Python driver (apache-age-python version 0.0.7)
What data setup do we need to do?
None - this warning occurs during module import and basic connection setup.
What is the necessary configuration info needed?
Python 3.6+ (warning becomes more visible in Python 3.12+)
apache-age-python 0.0.7
What is the command that caused the error?
importageimportpsycopg2# Warning appears during import or when using the libraryconn=psycopg2.connect(...)
age.setUpAge(conn, "test_graph")
Expected behavior
No warnings should be emitted. Regex patterns should use raw string literals (r'\s') to properly declare escape sequences.
Root Cause
In age/age.py line 28, the code uses:
WHITESPACE=re.compile('\s')
The \s is not a valid Python string escape sequence. While it currently works because Python interprets unrecognized escape sequences as literal characters, this behavior is deprecated.
Proposed Fix (#2267)
Change line 28 to use a raw string:
WHITESPACE=re.compile(r'\s')
This is backwards compatible and eliminates the warning across all Python versions.
Environment (please complete the following information):
apache-age-python Version: 0.0.7
Python Version: 3.12+ (but affects 3.6+)
PostgreSQL + AGE: Any version
Additional context
bpo-27364 - Python 3.6 introduced DeprecationWarning for invalid escape sequences
Activity