Skip to content

Don't let the default delimiter override a caller-supplied CSV dialect - #666

Open
Sanjays2402 wants to merge 1 commit into
jazzband:masterfrom
Sanjays2402:fix/csv-dialect-not-overridden
Open

Don't let the default delimiter override a caller-supplied CSV dialect#666
Sanjays2402 wants to merge 1 commit into
jazzband:masterfrom
Sanjays2402:fix/csv-dialect-not-overridden

Conversation

@Sanjays2402

Copy link
Copy Markdown

Fixes #622

CSVFormat.import_set and export_stream_set always applied DEFAULT_DELIMITER through kwargs.setdefault, so a caller passing dialect= (but no explicit delimiter=) got the default , injected alongside it — and csv gives the standalone delimiter precedence, silently ignoring the dialect's delimiter.

Now the default is only applied when no dialect was supplied. Regression test covers both the import and export paths with a sniffed : dialect; it fails on master and passes with the fix, and the full suite (181 tests) is green.

CSVFormat.import_set and export_stream_set unconditionally applied
DEFAULT_DELIMITER via kwargs.setdefault. A caller passing dialect= but no
explicit delimiter= therefore got the default ',' injected alongside the
dialect, and csv gives the standalone delimiter precedence, so the dialect's
delimiter was silently ignored.

Only apply the default when no dialect was supplied. Adds a regression test
covering both the import and export paths with a sniffed ':' dialect.

Fixes jazzband#622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple csv file can't be parsed correctly because of Sniffer() parameters

1 participant