Repository navigation
fix(corekit,utilities): unquote a StringField's bytes on Python 3.8 through compat.unquote (#1693) - #1707
Conversation
|
Verdict: GOOD TO GO at |
|
Coverage: 89.42% (unit tier, Python 3.15,
Per-file detail: the |
|
Several notes:
|
|
for 1, or easier, |
|
Recorded:
|
6246836 to
4a7f552
Compare
|
Verdict: GOOD TO GO at
|
|
Resolve conflicts |
|
Rebasing onto |
…hrough compat.unquote (#1693) StringField(unquote=True) handed the raw field octets to urllib.parse.unquote, which accepts bytes only from Python 3.9; on 3.8 every unquoting read raised "TypeError: Expected str, got bytes". pcapkit.utilities.compat now exports unquote behind a sys.version_info gate: from 3.9 it is urllib.parse.unquote itself; below 3.9 it spells out what 3.9 does for bytes, unquote_to_bytes(value).decode(encoding, errors), and passes anything else to the interpreter's own unquote. StringField imports it for both call sites, including the UnicodeError fallback, and the docs' compatibility table lists it. Tests: test_compat checks the running interpreter's unquote and the pre-3.9 branch (under the faked (3, 5), once more with a bytes-rejecting unquote) against one table pinned to 3.9's results; WARM_BEFORE_FAKING gains urllib.parse. The StringField table stays, plus a check that the field unquotes through compat.
|
resolve conflicts |
|
Conflicts resolved: rebased onto Verdict: GOOD TO GO at
|
4a7f552 to
e37c141
Compare
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort) — run on the changed files; no new findingsmake testpasses, and a test case covers the change — tests added; touched and related modules run, not the whole suiteAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
StringField(unquote=True)passed its raw octets tourllib.parse.unquote, which acceptsbytesonly from 3.9. On 3.8, every unquoting read raisedTypeError: Expected str, got bytes. No schema inpcapkitsetsunquote=True, so this hits user-built fields and the field tests.pcapkit.utilities.compatexportsunquotebehind asys.version_infogate. From 3.9 it isurllib.parse.unquoteitself; below 3.9 it does what 3.9 does forbytes,unquote_to_bytes(value).decode(encoding, errors), and passes anything else to the interpreter's ownunquote.StringFieldimports it for both call sites, including theUnicodeErrorfallback. The docs' compatibility table lists it.urllib.parse.unquoteand the helper agree on all 20,142 / 20,142 / 20,318 cases (everyencodings.aliasescodec × 8 error handlers × 22 byte strings, plusstr,bytearray,memoryview, abytessubclass,int,None), results and exception type, message andUnicodeErrorattributes alike. The pre-3.9 body is the helper's, so round 2's 882,855-record differential still describes it (not re-run).test_compatchecks the running interpreter'sunquote(urllib's own from 3.9) and the pre-3.9 branch, loaded under the faked(3, 5), against one 16-row table pinned to 3.9's results (bytes,str,bytearray,memoryview, defaults, bothUnicodeDecodeErrormessages), the branch once more with a bytes-rejectingunquote.WARM_BEFORE_FAKINGgainsurllib.parse. TheStringFieldtable stays, plus a check that the field unquotes throughcompat.test_compat, the touched module andtest_field_roundtrip_unit.pypass under pytest and plainunitteston 3.8.20, 3.9.25, 3.10.21 and 3.14.8. Dropping the fallback'sbytesbranch failstest_python35_fallback_implementationson 3.14 and five tests on 3.8;main'sstrings.pyfailstest_unquote_is_the_compat_oneon 3.14. On 3.14,test_compatplus thetests/corekit/field tests cover every statement and branch ofstrings.pyandcompat.py. A line trace shows the gate's statements all run on 3.9, 3.10 and 3.14; on 3.8 all but the 3.9+ import.pcapkit.Closes #1693