Skip to content

gh-155742: Use PyBytesWriter in winconsoleio.c - #157391

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:winconsoleio
Open

gh-155742: Use PyBytesWriter in winconsoleio.c#157391
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:winconsoleio

Conversation

@vstinner

@vstinner vstinner commented Sep 13, 2026

Copy link
Copy Markdown
Member

Replace soft deprecated _PyBytes_Resize() with PyBytesWriter.

Replace soft deprecated _PyBytes_Resize() with PyBytesWriter.
@vstinner

Copy link
Copy Markdown
Member Author

There is a second _PyBytes_Resize() call in readall(), but I left it unchanged because I don't understand the final resize:

    if (bytes_size < (size_t)PyBytes_GET_SIZE(bytes)) {
        if (_PyBytes_Resize(&bytes, n * sizeof(wchar_t)) < 0) {
            Py_CLEAR(bytes);
            return NULL;
        }
    }

I expected a resize using bytes_size, but n * sizeof(wchar_t) is used. Problem: I don't understand the relationship between the buffer size and n variable. Maybe it's a bug in the code?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants