Skip to content

Fix Python 3.10 – 3.12+ Compatibility (Hashing and Syntax)#235

Open
bharathananth wants to merge 2 commits intostephenslab:masterfrom
bharathananth:python310
Open

Fix Python 3.10 – 3.12+ Compatibility (Hashing and Syntax)#235
bharathananth wants to merge 2 commits intostephenslab:masterfrom
bharathananth:python310

Conversation

@bharathananth
Copy link

Description

This PR addresses several breaking changes and syntax warnings introduced in recent Python versions (3.10, 3.11, and 3.12). These changes ensure that dsc remains functional as older Python versions approach their End-of-Life (EOL).

Key Changes

Hashing Compatibility (Python 3.10+):

String Encoding: Updated all calls to xxh() and hashlib to encode Unicode strings to utf-8 bytes before hashing. This resolves TypeError: Strings must be encoded before hashing.

F-string Syntax: Fixed nested quote errors in dsc_parser.py that caused SyntaxError when using xxh inside list comprehensions.

Regex Refactoring (Python 3.12+):

Raw Strings: Converted strings containing escape sequences (e.g., [, (, {) to raw strings (r'...'). This resolves SyntaxWarning: invalid escape sequence, which is slated to become a hard SyntaxError in future Python releases.

Verification Results

I have verified these changes using the following steps:

[x] Vignette Testing: Successfully ran the official dsc vignettes (including one_sample_location (R scripts) and one_sample_location_python) to completion.

[x] Cache Integrity: Confirmed that the SoS caching mechanism correctly identifies and retrieves task results, proving that the updated hashing logic is consistent.

[x] Multi-Version Test: Verified the fix on Python 3.10, 3.11, and 3.12 environments.

Note on Dependencies

While this PR cleans up all SyntaxWarnings within the dsc source code itself, users may still see warnings originating from the PTable dependency (e.g., SyntaxWarning: "is" with a literal). These are upstream issues in PTable and do not affect the core logic of dsc. I recommend a future update to the dependency pins to a more modern version of prettytable to resolve those remaining notices.

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.

1 participant