Repository navigation
Preserve trailing whitespace in csvgrep matchfile patterns - #1367
Open
sakura168899-debug wants to merge 1 commit into
Open
sakura168899-debug wants to merge 1 commit into
sakura168899-debug wants to merge 1 commit into
Conversation
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.
Problem
csvgrep -fpromises exact cell matches after removing line separators from each matchfile entry. However,line.rstrip()also removes data-significant spaces, tabs and Unicode whitespace. A pattern"value "therefore selects a row containing"value"and misses the actual exact match. Inverted matching selects the opposite wrong set.Minimal reproduction (the space before
\nin the matchfile is intentional):Expected: the
exactrow, whose key is"value ". Before this change, thetrimmedrow is returned instead.Change
Restrict stripping to
\rand\n. This changes one line in the matchfile reader, without changing regex/string matchers, case sensitivity or row-filter logic.Regression tests cover trailing spaces, tabs, NBSP, em-space, whitespace-only patterns, LF/CRLF/CR/no final newline, multiple patterns, inverted matching and any/all-column modes. This does not implement the separate ignore-case proposal in #1356, whose current diff retains the original stripping behavior.
Validation
git diff --checkpass.python -m build --no-isolationsdist-to-wheel build, followed by a separatepip --targetinstallation.Validation is local on Windows / CPython 3.12.14. The other OS/Python CI matrix and check-manifest have not been run locally. Existing warnings are unchanged.
AI assistance
This patch and its tests were prepared with Codex (AI assistance). I am an external contributor, not a project maintainer.