Python 3.13/3.14 compatibility: fix escape sequence and cgi removal#553
Open
marcelo-srs wants to merge 1 commit intorawpython:masterfrom
Open
Python 3.13/3.14 compatibility: fix escape sequence and cgi removal#553marcelo-srs wants to merge 1 commit intorawpython:masterfrom
marcelo-srs wants to merge 1 commit intorawpython:masterfrom
Conversation
- Fix SyntaxWarning (→ SyntaxError in 3.14) from invalid escape sequence `\E` in server.py onerror debug string; replace with `\\E` - Replace removed `cgi` module (dropped in Python 3.13) with a try/except that imports `cgi.FieldStorage` on Python ≤3.12 and falls back to a minimal `_FieldStorage` implementation using `email.parser` on 3.13+ - Always define `remi.__version__`: set `_FALLBACK_VERSION = "2026.03.24"` before the importlib.metadata / pkg_resources lookup chain so the attribute is never undefined in PyInstaller frozen builds or bare source checkouts - Bump hardcoded fallback version to 2026.03.24 in both __init__.py and setup.py (kept in sync) - Add test/test_version.py with 7 test cases validated on Python 3.12, 3.13 and 3.14 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
Thank you very much @marcelo-srs 😉 |
pull bot
pushed a commit
to Pandinosaurus/remi
that referenced
this pull request
Mar 24, 2026
Python 3.13/3.14 compatibility: fix escape sequence and cgi removal
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.
Summary
This PR fixes three Python 3.13/3.14 compatibility issues found when using remi with PyInstaller and modern Python versions.
1. Fix invalid escape sequence
\Einserver.py(SyntaxWarning → SyntaxError)remi/server.pycontained\ERRORin a debug format string.\Eis not a valid Python escape sequence:SyntaxWarningSyntaxWarning(promoted to error by PyInstaller in frozen builds)SyntaxError— the module fails to import entirelyFix: changed
\ERROR→\\ERROR.2. Replace removed
cgimodulecgi.FieldStoragewas deprecated in Python 3.11 and removed in Python 3.13. It was used indo_POSTto parse multipart/form-data file uploads.Fix: wrapped the import in a try/except:
cgi.FieldStorageas before — no behaviour change_FieldStoragedrop-in built onemail.parserthat exposes the same.keys()/.__getitem__()/.filename/.fileinterface3. Ensure
remi.__version__is always defined (PyInstaller / frozen builds)__init__.pylooked up the version viaimportlib.metadata, thenpkg_resources, and silentlypassed if neither could find the package. In PyInstaller frozen builds the package metadata is typically absent, leaving__version__undefined and causingAttributeErroron access.Fix: set
__version__ = _FALLBACK_VERSION(hardcoded"2026.03.24") before the lookup chain. The metadata lookup still overrides it when available; the fallback guarantees__version__is always a valid string.Version bumped to
2026.03.24in both__init__.pyandsetup.py.New tests —
test/test_version.pyTestNoSyntaxWarnings.test_server_py_no_syntax_warningsserver.pywith-W error::SyntaxWarning— asserts no warnings/errorsTestVersionAlwaysDefined.test_version_is_stringremi.__version__is always astrTestVersionAlwaysDefined.test_version_non_emptyremi.__version__is never emptyTestVersionImportlibMetadataPath.test_importlib_metadata_usedimportlib.metadata.version()succeeds, its value is usedTestVersionPkgResourcesFallback.test_pkg_resources_fallbackimportlib.metadatais absent,pkg_resourcesprovides the versionTestVersionHardcodedFallback.test_hardcoded_fallback_usedPackageNotFoundError, hardcoded fallback is usedTestVersionHardcodedFallback.test_fallback_version_matches_setup_FALLBACK_VERSIONin__init__.pystays in sync withsetup.pyTest results across Python versions
All 7 new tests pass on every tested version. The 4 pre-existing failures (missing optional
matplotlib/PILdeps, and twoassertEqualscalls deprecated since 3.12) are unchanged and unrelated to this PR.Python 3.12.8
Python 3.13.1
Python 3.14.3
🤖 Generated with Claude Code