feat: python2 to python3#9
Open
zeidlitz wants to merge 3 commits into
Open
Conversation
zeidlitz
force-pushed
the
feat/python2-to-python3
branch
2 times, most recently
from
November 29, 2025 21:32
c95215d to
f832360
Compare
The test suite could not run at all in this PR: every test file mixed a bare `from BaseTestCase import X` (needs tests/ on sys.path) with `from lib import X` (needs the repo root on sys.path), while the leftover sys.path.insert only added <repo_root>/lib, satisfying neither. Normalized every test file + BaseTestCase.py to insert the repo root and import BaseTestCase via `tests.BaseTestCase`. Also gave lib/processor.py and lib/networks.py package-relative imports for ipcalc, since bare `import ipcalc` only worked when lib/ itself was on sys.path (the old, now-abandoned convention). Real bugs found once the suite could actually run: - TestParser.py: testParseNetwork/testParseNetworkNoVlan silently lost their processor.network(...) setup calls during the port, so they asserted against an empty table. Restored them. - processor.py host(): vlan lookup used the host's own freshly-created node_id instead of the passed-in network_id, so vlan (and therefore IPv6 address generation) was always None. Also dropped a bogus `row[5] = json.dumps(row[5])` that JSON-encoded the network_id foreign key before insert. - processor.py network(): `len(net_ipv4)` crashed (ipcalc.Network has no __len__) on every call; and the function returned a (node_id, network_id) tuple instead of just node_id, corrupting parse()'s network_id tracking for every host/network line after the first network definition in a file. - lib/packages.py, lib/firewall.py: leftover `.iteritems()` calls (removed in Python 3). One of them (firewall.py's redundant-flow pruning loop) had also lost its `node, services` tuple unpacking, silently disabling that logic entirely rather than crashing. - lib/location.py switch_locations(): `/` now does true division in Python 3 where Python 2 silently floor-divided, producing fractional pixel coordinates. Restored `//` to keep whole-pixel output. - lib/ipcalc.py: removed a redundant duplicate `self.mask = int(...)` line. - requirements.txt: removed `requests`, `layout`, `ipcalc`, `six`, `processor` (layout/ipcalc/processor are this project's own lib/ modules, not PyPI packages; requests/six are unused), and bumped PyYAML off the ancient 3.11 pin, which fails to build against modern CPython. - makefile: test/coverage/draw targets still invoked python2.7. TestSeatmap.testAddCoordinates/testSwitchLocation/ testSwitchLocationWithMixedLayout expectations updated for two inherent, unavoidable Python 2->3 differences that surfaced once the suite could run: dict iteration order (insertion-order in Py3 vs hash-order in Py2) changes which hall's switches get inserted first, and round()'s tie-breaking rule (round-half-to-even in Py3 vs round-half-away-from-zero in Py2) changes one scaled-width value by 2px. Verified: full test suite passes under Python 3, and an end-to-end `generate.py` run against real fixture data produces correct host vlan/IPv6/network_id data (previously broken by the host() bug above).
SoundGoof
force-pushed
the
feat/python2-to-python3
branch
from
July 26, 2026 18:43
66e573e to
62ca988
Compare
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.
the goal with this change is to make the source in this project compatible with python3 while keeping any previous python2 logic intact