Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding bpo info in code
  • Loading branch information
shihai1991 committed Feb 10, 2020
commit f013d98ddac940341376675817273f91847ac1f4
1 change: 1 addition & 0 deletions Modules/_ctypes/cfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length)
}

data = PyBytes_AS_STRING(value);
/* bpo-39593: XXX Why not Py_SIZE(value)? */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that it's correct to add a test which indirectly specify the behavior and keep this comment which suggests to change the behavior.

I suggest to rewrite the comment to explain that we do use strlen() on purpose, rather than PyBytes_GET_SIZE() since we truncate characters after a null character on purpose. Keep the bpo number in the comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, got it. I updated the description info, do you think it's clear enough?

size = strlen(data);
Comment thread
shihai1991 marked this conversation as resolved.

if (size < length) {
Expand Down