Skip to content

Conversation

@mhsong21
Copy link

@mhsong21 mhsong21 commented Sep 24, 2025

Use PyBytesWriter in _PySSL_BytesFromBIO

@python-cla-bot
Copy link

python-cla-bot bot commented Sep 24, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Sep 24, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@mhsong21
Copy link
Author

@corona10 this pr is ready

return NULL;
}
char *str = PyBytesWriter_GetData(writer);
memcpy(str, data, size);
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, @vstinner,
Isn’t PyBytesWriter_WriteBytes not really intended for this use case? Looking at the current codebase, most cases seem to just use memcpy.

Copy link
Member

Choose a reason for hiding this comment

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

I also think that this is not needed.

@corona10 corona10 marked this pull request as ready for review September 24, 2025 07:06
@corona10 corona10 requested a review from vstinner September 24, 2025 07:06
@corona10 corona10 self-assigned this Sep 24, 2025
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

PyBytes_FromStringAndSize(data, size) is just fine. I don't see the point of replacing it.

PyBytesWriter is cleaner to replace PyBytes_FromStringAndSize(NULL, size).

@bedevere-app
Copy link

bedevere-app bot commented Sep 24, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@corona10
Copy link
Member

PyBytes_FromStringAndSize(data, size) is just fine. I don't see the point of replacing it.

Ah got it, I missed this deprecation message.

``PyBytes_FromStringAndSize(NULL, len)`` is :term:`soft deprecated`,
      use the :c:type:`PyBytesWriter` API instead.

@mhsong21 I think that you should find out usecase that are using PyBytes_FromStringAndSize(NULL, len) currently.

@corona10 corona10 closed this Sep 24, 2025
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.

4 participants