jsell-rh opened a new issue, #2268:
URL: https://github.com/apache/age/issues/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?**
   ```python
   import age
   import psycopg2
   
   # Warning appears during import or when using the library
   conn = psycopg2.connect(...)
   age.setUpAge(conn, "test_graph")
   ```
   
   **Warning output:**
   
   **Python 3.6-3.11:**
   ```
   DeprecationWarning: invalid escape sequence '\s'
     WHITESPACE = re.compile('\s')
   ```
   
   **Python 3.12+:**
   ```
   SyntaxWarning: invalid escape sequence '\s'
     WHITESPACE = re.compile('\s')
   ```
   
   **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:
   ```python
   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:
   ```python
   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](https://bugs.python.org/issue27364) - Python 3.6 introduced 
DeprecationWarning for invalid escape sequences
   - [Python 3.12 What's New](https://docs.python.org/3/whatsnew/3.12.html) - 
Upgraded to SyntaxWarning in 3.12
   - Python 3.14+ will likely make this a hard SyntaxError
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to