Repository navigation
d3d12_guid_sites: an image, --header or --json path it cannot read is one ERROR line and exit 2 - #5737
d3d12_guid_sites: an image, --header or --json path it cannot read is one ERROR line and exit 2#5737evilclanker9000 wants to merge 1 commit into
Conversation
… not a traceback The image loop catches (ValueError, struct.error) only, so a mistyped image path ends in FileNotFoundError; --header that is not a file was dropped by os.path.isfile() and the scan reported every interface as UNKNOWN; the --json write caught nothing. All three now print one ERROR line and return 2, as tools/d3d12_iid_scan.py does. Test: tests/test_d3d12_guid_sites.py (hand-built PE32+ fixtures, no game files).
Kam471
left a comment
There was a problem hiding this comment.
Reviewed head 2617077 (base 561b65a).
git diff --checkclean.python -I -m pytest tests/test_d3d12_guid_sites.py -q-> 8 passed.- Covers an unreadable image,
--headerand--json: oneERROR:line, exit 2, no traceback. The t6 test now uses an existing empty header, matching that a missing--headeris an error. default_header()only returns an existing file, so a machine without the SDK is unaffected.
Verdict: merge; this supersedes #5735 (close that one as the duplicate).
|
Tested Negative control. With so the traceback is really there on The messages use One thing worth resolving before review: #5735 (same author, 20 seconds earlier) is a strict subset of this — the same image and AI-assisted. |
tools/d3d12_guid_sites.pyreports an unreadable path as one line, where it used to end in a traceback or silently say nothing.What and why
FileNotFoundErrortraceback: thetryinmain()catches(ValueError, struct.error)(a bad PE) only, soscan()'sopen()escapesERROR: cannot read <path>: <reason>, exit 2--headerif header and os.path.isfile(header)dropped a path that is not a file, so the scan printed0 known GUIDsand every interface came outUNKNOWNERROR: cannot read <path>: <reason>, exit 2 (the default SDK header still just means "no header", as before)--jsonopen(args.json, "w")caught nothingERROR: cannot write <path>: <reason>, exit 2The wording and the exit code are
tools/d3d12_iid_scan.py's (ERROR: cannot read <path>: <reason>, exit 2), so two tools that read the same images fail the same way. The module docstring now says so too.Test
python -I tests/test_d3d12_guid_sites.py— newtest_unreadable_paths_are_one_error_lineruns the CLI three times (missing image, missing--header,--jsoninto a missing folder) and asserts exit 2, exactly oneERROR:line on stderr, and noTraceback. All fixtures are hand-built PE32+ images from the test's ownpe32plus()helper: no game files, no Windows SDK, no GPU.Before (
tests/test_d3d12_guid_sites.pyat561b65a83, tool unchanged):After:
The three cases by hand:
python -m compileall -q tools testsis clean.GPU
No GPU needed; nothing here touches the runtime or the translator.
Notes
--headerpath that does not exist is now an error. That is the one behaviour change: it used to be treated as "no header". Keeping it silent is what makes a mistyped--headerreport every interface asUNKNOWNwithout a word, and--known,--jsonand the siblingd3d12_iid_scanall fail on a bad argument, so I chose consistency. Only a header given explicitly errors:default_header()returningNone(no Windows SDK installed) still just means "no known IIDs".tests/test_d3d12_guid_sites.py:test_cliused the nonexistent path<tmp>/none.has a shortcut for "no known IIDs"; it now writes an empty<tmp>/none.hinstead, which is the same thing without the new error.== <image>: skipped (...)line for a file that is readable but not a PE image alone: that is content, not a path, and the scan can go on to the next image.Task: EGEN-GUID-SITES-PATHS (posted as a
finding:in #5581).AI-assisted.