Make spyne ready for Python 3.14 - #723
Open
carloscbl wants to merge 6 commits into
Open
Conversation
|
@carloscbl could you split items 1-5 up into separate commits? would make the PR easier to review |
- protocol/http.py:438: use rb-string to fix '\.' escape SyntaxWarning
(mirrors the raw-string sub already used on the line above, for the bytes path)
- protocol/json.py: mark module docstring raw to silence '\s' SyntaxWarning
- util/invregexp.py: mark docstring raw ('\d' escape in an example regex)
These become SyntaxError in a future Python release.
protocol/cloth/to_cloth.py:770 had an unconditional 'break' inside a 'finally:' block, flagged as a SyntaxWarning on Python 3.14. The break runs unconditionally after the inner try/except StopIteration, so it can be hoisted out of the finally without changing happy-path semantics.
server/twisted/http.py uses cgi.FieldStorage for multipart parsing. PR arskom#713 covered cgi.parse_header but FieldStorage was untouched. - wrap 'import cgi' in try/except ImportError, falling back to the maintained 'legacy-cgi' PyPI package if installed - if neither is available and the multipart path is actually executed, raise a descriptive RuntimeError telling the user to install legacy-cgi Users who don't use multipart over Twisted pay nothing. A full rewrite of multipart parsing is out of scope.
Replaced assertEquals, assertNotEquals, assertRegexpMatches, assertRaisesRegexp and failUnlessEqual with their non-deprecated names in: - test/interop/test_django.py - test/multipython/model/test_complex.py - test/protocol/_test_dictdoc.py The shared _test_dictdoc base is why test_json/test_msgpack/test_yaml had 6 collective failures on 3.12+.
Added the 3.11, 3.12, 3.13 and 3.14 classifiers without dropping older entries (can be decoupled to a follow-up release if preferred).
carloscbl
force-pushed
the
sm/python-3.14
branch
from
July 23, 2026 09:26
30badd4 to
4dd2bb7
Compare
Author
Done! |
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
Brings spyne up to date with the current CPython release line. After this PR,
import spyneand the model/protocol/interface test suites pass cleanly on Python 3.11, 3.12, 3.13 and 3.14 — noSyntaxWarning, noSyntaxError, no removed-stdlib import failures.Tested on
python:3.14-slim: 526/526 tests pass inspyne/test/{model,protocol,interface}andpython -m compileall spyneis silent under-W error::SyntaxWarning.What's in the box
1. Invalid string-escape
SyntaxWarning(will beSyntaxErrorin a future Python)spyne/protocol/http.py:438—b'(?P<\\1>[^\.]*)'→ raw bytestringrb'(?P<\1>[^\.]*)'. The original sub already used a raw-string version on the line above; this is the same pattern but for the bytes path.spyne/protocol/json.py— module docstring contains\sand\d-like sequences. Marked the docstring as raw (r"""…""").spyne/util/invregexp.py— same fix on theinvregexpdocstring (contains\dinside an example regex).2. PEP 765 (Python 3.14):
break/continue/returninfinallyspyne/protocol/cloth/to_cloth.py:770had abreakinside afinally:block, which Python 3.14 flags as aSyntaxWarning. The break was unconditional after the innertry/except StopIteration, so it can be hoisted out of thefinallywithout changing the happy-path semantics. Added a one-line comment pointing to PEP 765.3.
cgimodule removed in Python 3.13spyne/server/twisted/http.pyusescgi.FieldStoragefor multipart parsing in the Twisted HTTP server. PR #713 already addressedcgi.parse_header, butFieldStoragewas untouched.This PR keeps the existing code path working without forcing a heavy dependency on everyone:
import cgiis wrapped in atry/except ImportError, falling back to thelegacy-cgiPyPI package (a maintained fork of the stdlibcgimodule) if it is installed.RuntimeErrorwith a clear message telling the user topip install legacy-cgi. Users who don't use multipart over Twisted pay nothing.A full rewrite of multipart parsing is out of scope here — this is the minimum viable change to keep 3.13/3.14 users running.
4. Deprecated
unittestaliases removed in Python 3.12The test suite still used
assertEquals,assertNotEquals,assertRegexpMatches,assertRaisesRegexpandfailUnlessEqual, all of which were removed in 3.12. Replaced mechanically with their non-deprecated names in:spyne/test/interop/test_django.pyspyne/test/multipython/model/test_complex.pyspyne/test/protocol/_test_dictdoc.py(That last file is why
test_json.py,test_msgpack.pyandtest_yaml.pyhad 6 collective failures on 3.12+ — same shared base.)5. Classifiers
Added
Python :: 3.11,3.12,3.13,3.14tosetup.py. Did not drop the older entries — happy to do that in a follow-up if you'd rather couple it to a release.6. Version bump
Bumped
__version__from2.15.0-alphato2.15.0and added aCHANGELOG.rstentry. If you'd prefer to keep the alpha tag and roll your own release, just drop those two hunks — the rest stands on its own.Out of scope (intentionally)
cgientirely.FutureWarningfrom lxml about truth-testing elements inprotocol/soap/soap12.py. It's pre-existing and unrelated to 3.14.wsgiref"iterator garbage collected without being closed" warning from a couple of tests — also pre-existing.spyne/util/six.py— left alone; it's still used internally and Python 2 deprecation is a separate conversation.Test plan
python -m compileall -q spyneclean under-W error::SyntaxWarningon 3.14import spyne; from spyne import Application, ServiceBase, rpc; from spyne.protocol.soap import Soap11, Soap12; from spyne.server.wsgi import WsgiApplicationsucceeds on 3.14pytest spyne/test/{model,protocol,interface} -q→ 526 passed, 0 failed on 3.14