Repository navigation
Conversation
…ta#2941) Windows PowerShell 5.1 saves `pip freeze > requirements.txt` as UTF-16 LE with a BOM, and many Windows editors save UTF-8 with a BOM. pip decodes the file by its BOM, but the dependency-manifest reader in pass_k8s took the raw bytes. UTF-16 ended at the NUL after the first letter, so the file gave one bogus Package ("\xff\xfe" + "r") and none of its dependencies, and a UTF-8 BOM stuck to the first package name. Decode the manifest once after reading it: drop a UTF-8 BOM, and transcode UTF-16 LE/BE with a BOM to UTF-8. go.mod goes through the same reader. Files without a BOM are read exactly as before. Signed-off-by: Wei-Lun Li <b84330808@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
This branch has not been deployed
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.
What does this PR do?
Fixes #2941.
pip reads
requirements.txtby its BOM, and Windows tools write BOMs. Windows PowerShell 5.1 savespip freeze > requirements.txtas UTF-16 LE with a BOM and CRLF, and many editors save UTF-8 with a BOM. The dependency-manifest reader inpass_k8s.ctook the raw bytes:\xff\xfe+r(the@bytes:fffe72in the issue) and none of the real dependencies.EF BB BFbeforeannotated-doc==0.0.4).The fix decodes the manifest once, right after
k8s_read_fileink8s_prep_file. It drops a UTF-8 BOM, and it transcodes UTF-16 LE/BE with a BOM to UTF-8 (surrogate pairs combined, an unpaired surrogate becomes U+FFFD). go.mod goes through the same reader, so it gets the same handling. A file without a BOM is read exactly as before.Tests, in
tests/test_grammar_probe_f.cnext to the go.mod group. Each indexes a project with onlyrequirements.txt(requests==2.32.3,uvicorn==0.30.0, CRLF) and checks the sorted Package names:probe_requirements_utf16le_bom_issue2941: UTF-16 LE with a BOM, the PowerShell 5.1 case.probe_requirements_utf16be_bom_issue2941: UTF-16 BE with a BOM.probe_requirements_utf8_bom_issue2941: UTF-8 with a BOM.probe_requirements_utf8_plain_issue2941: plain UTF-8, unchanged behaviour.How I ran them: on ubuntu-24.04 (GitHub Actions on my fork),
make -f Makefile.cbm test-focused TEST_SUITES=grammar_probe_fgives 188 passed, andscripts/test.shends withAll tests passed. Withpass_k8s.creverted to main and the new tests kept, the suite gives 185 passed, 3 failed: the three BOM tests (e.g."uvicorn,requests" != "requests,uvicorn"for the UTF-8 BOM case); the plain UTF-8 test passes either way.Locally (Windows, no make or zlib) I compiled
pass_k8s.cand the test file with zig cc 0.16 (clang 20,-target x86_64-linux-gnu, the Makefile's-Wall -Wextra -Werrorset): both clean. I also ran the decoder andparse_requirements_deps, copied out ofpass_k8s.cinto a small harness built with UBSan:\xff\xferrequests,uvicorn\xfe\xffrequests,uvicorn\xef\xbb\xbfrequests,uvicornrequests,uvicornrequests,uvicornrequests,uvicornpass_k8s.chas no clang-format 20.1.8 drift. I haven't run cppcheck or clang-tidy.I used Claude Code to write this change.
Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)