Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(159643)

Unified Diff: Modules/fcntlmodule.c

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
--- a/Modules/fcntlmodule.c Wed Mar 18 21:36:23 2015 -0500
+++ b/Modules/fcntlmodule.c Thu Mar 19 13:16:44 2015 +0200
@@ -62,20 +62,22 @@ fcntl_fcntl_impl(PyModuleDef *module, in
{
unsigned int int_arg = 0;
int ret;
- char *str;
+ Py_buffer view;
Py_ssize_t len;
char buf[1024];
if (arg != NULL) {
int parse_result;
- if (PyArg_Parse(arg, "s#", &str, &len)) {
- if ((size_t)len > sizeof buf) {
+ if (PyArg_Parse(arg, "s*", &view)) {
+ if ((size_t)view.len > sizeof buf) {
Martin Panter 2015/03/20 02:41:08 Probably should release the buffer in this case
storchaka 2015/03/20 07:47:34 Done.
PyErr_SetString(PyExc_ValueError,
"fcntl string arg too long");
return NULL;
}
- memcpy(buf, str, len);
+ len = view.len;
+ memcpy(buf, view.buf, len);
Martin Panter 2015/03/20 02:41:08 An argument could be made for passing the buffer d
storchaka 2015/03/20 07:47:34 Agree with you, this is not easy issue. I'll left
+ PyBuffer_Release(&view);
Py_BEGIN_ALLOW_THREADS
ret = fcntl(fd, code, buf);
Py_END_ALLOW_THREADS
« Doc/library/socket.rst ('K') | « Modules/_codecsmodule.c ('k') | Modules/mmapmodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+