756: support for / test with python 3.13#768
Merged
lognaturel merged 3 commits intoXLSForm:masterfrom Jun 6, 2025
Merged
Conversation
lognaturel
previously approved these changes
Jun 3, 2025
Contributor
Author
|
@lognaturel Yeah hoping this would be a quick one but it looks like some standard library changes - |
- formencode==2.1.1 supports py3.9 to py3.13
- in py3.13, minidom was updated to only escape " in attributes, which is what pyxform has been doing for a while. It also now escapes \r\n\t in attributes, which pyxform was not doing, but appears to be the right behaviour according to the XML spec and related python tickets, so now pyxform does that for all supported versions.
lognaturel
approved these changes
Jun 6, 2025
Contributor
lognaturel
left a comment
There was a problem hiding this comment.
Breaking Python 3.7 and 3.8 feels like no problem.
I really doubt tabs and newlines are common in attributes. The only context in which I think they could make sense is in constraint and required messages. Let’s go with this and if there are any issues we will learn something.
Contributor
|
I was wrong! Some users do use newlines in calculations and constraints for readability. I should have thought of that because I do it too. Those aren't typically a problem but there seem to be cases in which they crash Enketo: #771 |
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.
Closes #756
Why is this the best possible solution? Were any other approaches considered?
To align with pyodk python version support. According to the python website, 3.14 is due out 2025-10 and 3.10 goes EOL 2026-10.
What are the regression risks?
The XML escaping algo changed in python 3.13 to what seems to be a more correct way (referring to normalization rules in the XML spec) - namely, to escape
\r\n\tin attribute values. So pyxform now does that too, for all supported python versions. Pyxform already was overriding some escaping behaviour, because prior to python 3.13 double quotes were escaped in element text but they only need to be escaped in attributes. Unfortunately python implemented the change in a non-backwards compatible way, by adding a new requiredattrargument, with no default, to the_write_datafunc that pyxform was using. In any case pyxform would have needed to do something to maintain compatibility with 3.10 through 3.13 since the new output is different.The regression risk then is perhaps tab or newlines characters might have some kind of impact on Collect/Webforms/Enketo behaviour e.g. if they were normalised out before and now will be preserved due to escaping, or if any of the form clients don't recognise the escape codes and suddenly users see the escape codes instead of whitespace or nothing. There is the workaround for users to remove these characters from the XLSForm but generally pyxform tries to smooth over friction points like that. If these regression scenarios are a concern we could do some testing to check, and/or not escape
\r\n\tin attributes in pyxform, or not emit\r\n\tvalues in attributes, etc.The dev dependency update to formencode drops support for python 3.7 and 3.8 but that should not affect users. Could be an issue for library users but it's difficult to avoid since the update is required for python 3.13 compatibility. The alternative is to remove this dev dependency, but that would require refactoring all of the remaining "old style" tests that use formencode for XML document comparison.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Updated readme.
Before submitting this PR, please make sure you have:
testspython -m unittestand verified all tests passruff format pyxform testsandruff check pyxform teststo lint code