Repository navigation
fix(corekit): IPv4InterfaceField keeps non-netmask masks; OrderedMultiDict deepcopy keeps order - #1346
Conversation
|
Cross-review verdict on The field cannot pack its own parsed value's string form. I measured it in the PR worktree:
Also fix: On rejection vs keeping: no new ruling is needed. The owner's standing every-round-trip-matches ruling means a mask that is on the wire must survive the rebuild. The old rejection test came from #465, whose point was a Correction to the review: it reported #1295 confirmed:
|
69466d9 to
fef87f3
Compare
|
Round-2 verdict on
Merge depends on #1294's ruling. The string-parsing change is the one now waiting on the owner: Nits: a |
…iDict deepcopy keeps order - IPv4InterfaceField.post_process read a hostmask-shaped mask (0.0.0.255) as a prefix length and packed a different netmask; a non-contiguous mask raised. A mask that is not a contiguous netmask now unpacks to an IPv4Interface subclass that keeps the four octets. Its str() is dotted, or 0xXXXXXXXX when the dotted form would read as a hostmask, and pre_process reads either form literally only when ip_interface rejects the string, so stdlib-legal strings keep their meaning and every wire mask survives str() and pack. Equality and ordering use the mask (#1294). - OrderedMultiDict.deepcopy rebuilds from items(multi=True) instead of the inherited, key-grouping to_dict(flat=False); the werkzeug port of MultiDict is left verbatim (#1295). Closes #1294 Closes #1295
fef87f3 to
5bb3477
Compare
|
Round-3 verdict on Strings the stdlib accepts keep the stdlib's meaning:
The hex form follows BSD Evidence:
|
|
Coverage: 88.97% (unit tier, Python 3.14,
Per-file detail: the |
make pylint,make mypy,make isort) —mypy/pylint(Makefile flags) run onipaddress.pyonly;isortnot runmake testpasses, and a test case covers the change — only the modules listed below, plustests/projectdocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, added centrallyWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1294
Closes #1295
Base:
13aa677be._RawMaskIPv4Interface, anIPv4Interfacesubclass that keeps the four octets.pre_processtriesipaddress.ip_interfacefirst. Netmasks, prefix lengths and hostmasks (10.0.0.1/0.0.0.255is/24) pack exactly as onmain. Only a string the stdlib rejects is read with a literal mask: a non-contiguous dotted mask, or0xplus eight hex digits.str(): dotted, except a hostmask-shaped mask, which is written as0x000000ff. Hex follows the BSDifconfignetmask convention, the stdlib rejects it, and it keeps all 32 bits.pack(str(unpack(wire))) == wirefor every mask.hashuse the mask.networkandwith_prefixlenreport/32.FieldValueError, and two strings that raised onmainnow pack (…/255.0.255.0,…/0x000000ff). Every stringmainaccepted packs the same as before. The old rejection test came from Address fields let a bare ValueError escape for a malformed address, one line before FieldValueError is raised for a version mismatch #465, which was about the exception type, and is rewritten as…_keeps_….OrderedMultiDict.deepcopyrebuilds fromitems(multi=True), and__deepcopy__reaches it. werkzeug 2.2.3'sMultiDict.copy/deepcopy/__copy__/__deepcopy__match ours verbatim and are untouched.Tests:
test_ipv4interface_mask_unitchecks 100,063 masks (33 netmasks, 33 hostmasks and seeded random ones) forpack(str(unpack(wire))) == wire. It compares every stdlib-legal string withip_interface(s).netmask(all 33 prefixes, netmasks and hostmasks) and checks 10 malformed strings. Withfef87f31e'sipaddress.py: 38 failed, 6 passed. Withmain's: the earlier proof stands. All pass with the fix, as dotest_ordered_multidict_copy_unit,test_fields_ipaddress,test_multidict,test_pcapng_unitandtests/project. Thecorekitleg reports the same 5test_sentinel_exports_unitfailures with and without this change on13aa677be.Fixtures: per-frame
infoover the 23examples/capturesfiles is identical before and after. The count is regenerated bymake_samples, so it is not stable; this tree measured 1614 frames.