Fix Python 3.12 compatibility issues: escape sequences, builtin signatures, and error messages#60
Merged
thorwhalen merged 3 commits intomasterfrom Oct 15, 2025
Merged
Conversation
Co-authored-by: thorwhalen <1906276+thorwhalen@users.noreply.github.com>
Co-authored-by: thorwhalen <1906276+thorwhalen@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dol to work with Python 3.12
Fix Python 3.12 compatibility issues: escape sequences, builtin signatures, and error messages
Oct 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR fixes all Python 3.12 compatibility issues identified in #XX (link to issue). All 366 tests now pass successfully with no syntax warnings.
Issues Fixed
1. Invalid Escape Sequence Warnings
Python 3.12 enforces stricter escape sequence handling in string literals. Docstrings containing regex patterns like
\dand\wwere causingSyntaxWarningerrors.Fixed by:
dol/paths.py,dol/trans.pydol/paths.pyanddol/tests/test_paths.py2. Doctest Collection Error with Decorated Classes
The
CachedSequenceKvReaderclass was causing anAttributeErrorduring doctest collection:Root cause: In
dol/caching.py, the@wraps(store)decorator on__init__was incorrectly wrapping with the class instead of the class's__init__method, causinginspect.unwrap()to fail.Fixed by: Changed
@wraps(store)to@wraps(store.__init__)3. Builtin Signature Changes
Python 3.12 now provides signatures for many builtins that previously didn't have them (like
print), breaking doctests that expectedhas_signature(print)to returnFalse.Fixed by:
dol/signatures.pyto usemapinstead ofprint(map still has no signature)has_signaturetest from 2 to 34. Error Message Changes
Python 3.12 changed TypeError messages for keyword-only arguments from:
to:
Fixed by: Updated expected error messages in multiple signature doctests
5. OrderedDict Repr Changes
Python 3.12 changed
OrderedDictrepr format fromOrderedDict([('key', 42)])toOrderedDict({'key': 42}).Fixed by: Updated doctest to use
# doctest: +ELLIPSISwith flexible pattern matching6. UserDict Behavior Clarification
Updated
CascadedStoresdoctest to reflect actual behavior wheredict.get()doesn't trigger__getitem__when key is missing.Test Results
Files Changed
dol/caching.py- Fixed@wrapsdecorator usagedol/paths.py- Raw string docstrings and doctest updatesdol/signatures.py- Updated for builtin signature changes and error messagesdol/sources.py- Fixed doctest expectationdol/tests/test_paths.py- Raw string literals in testsdol/trans.py- Raw string docstringAll changes are minimal and surgical, focused solely on Python 3.12 compatibility without altering functionality.
Original prompt
Fixes #59
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.