Skip to content

Conversation

maurycy
Copy link
Contributor

@maurycy maurycy commented Aug 20, 2025

Please see for the code:

  • cpython/Modules/_csv.c

    Lines 1253 to 1267 in 7dc42b6

    if (!field_len && dialect->delimiter == ' ' && dialect->skipinitialspace) {
    if (dialect->quoting == QUOTE_NONE ||
    (field == NULL &&
    (dialect->quoting == QUOTE_STRINGS ||
    dialect->quoting == QUOTE_NOTNULL)))
    {
    PyErr_Format(self->error_obj,
    "empty field must be quoted if delimiter is a space "
    "and skipinitialspace is true");
    return 0;
    }
    quoted = 1;
    }
    rec_len = join_append_data(self, field_kind, field_data, field_len,
    &quoted, 0);

Please see the test:

The behavior is intentional since gh-115721, so the only sensible route is to update the docs.


📚 Documentation preview 📚: https://cpython-previews--138006.org.readthedocs.build/

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is too verbose. The note takes up a lot of space and attracts a disproportionate amount of attention. Most users will never encounter this, and if they do, this behavior is expected and therefore does not require any special explanation.

Could you please limit yourself to one short sentence? That such CSV files cannot contain empty fields.

@maurycy
Copy link
Contributor Author

maurycy commented Aug 21, 2025

I think this is too verbose. The note takes up a lot of space and attracts a disproportionate amount of attention. Most users will never encounter this, and if they do, this behavior is expected and therefore does not require any special explanation.

Could you please limit yourself to one short sentence? That such CSV files cannot contain empty fields.

Thank you for taking a look. Made it much shorter:

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 22, 2025
Copy link
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
And thanks for fixing the typo :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants