Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8182b717
Commit
8182b717
authored
Jul 28, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #8991: convertbuffer() rejects discontigious buffers
parent
84befb00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
21 deletions
+10
-21
Misc/NEWS
Misc/NEWS
+2
-0
Python/getargs.c
Python/getargs.c
+8
-21
No files found.
Misc/NEWS
View file @
8182b717
...
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 1?
...
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #8991: convertbuffer() rejects discontigious buffers.
- Issue #7616: Fix copying of overlapping memoryview slices with the Intel
- Issue #7616: Fix copying of overlapping memoryview slices with the Intel
compiler.
compiler.
...
...
Python/getargs.c
View file @
8182b717
...
@@ -1246,13 +1246,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
...
@@ -1246,13 +1246,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
PyErr_Clear
();
PyErr_Clear
();
return
converterr
(
"read-write buffer"
,
arg
,
msgbuf
,
bufsize
);
return
converterr
(
"read-write buffer"
,
arg
,
msgbuf
,
bufsize
);
}
}
if
(
!
PyBuffer_IsContiguous
((
Py_buffer
*
)
p
,
'C'
))
{
PyBuffer_Release
((
Py_buffer
*
)
p
);
return
converterr
(
"contiguous buffer"
,
arg
,
msgbuf
,
bufsize
);
}
if
(
addcleanup
(
p
,
freelist
,
cleanup_buffer
))
{
if
(
addcleanup
(
p
,
freelist
,
cleanup_buffer
))
{
return
converterr
(
return
converterr
(
"(cleanup problem)"
,
"(cleanup problem)"
,
arg
,
msgbuf
,
bufsize
);
arg
,
msgbuf
,
bufsize
);
}
}
if
(
!
PyBuffer_IsContiguous
((
Py_buffer
*
)
p
,
'C'
))
return
converterr
(
"contiguous buffer"
,
arg
,
msgbuf
,
bufsize
);
break
;
break
;
}
}
...
@@ -1274,41 +1276,26 @@ convertbuffer(PyObject *arg, void **p, char **errmsg)
...
@@ -1274,41 +1276,26 @@ convertbuffer(PyObject *arg, void **p, char **errmsg)
*
errmsg
=
NULL
;
*
errmsg
=
NULL
;
*
p
=
NULL
;
*
p
=
NULL
;
if
(
pb
==
NULL
||
if
(
pb
!=
NULL
&&
pb
->
bf_releasebuffer
!=
NULL
)
{
pb
->
bf_getbuffer
==
NULL
||
*
errmsg
=
"read-only pinned buffer"
;
pb
->
bf_releasebuffer
!=
NULL
)
{
*
errmsg
=
"bytes or read-only buffer"
;
return
-
1
;
return
-
1
;
}
}
if
(
PyObject_GetBuffer
(
arg
,
&
view
,
PyBUF_SIMPLE
)
!=
0
)
{
if
(
getbuffer
(
arg
,
&
view
,
errmsg
)
<
0
)
*
errmsg
=
"bytes or single-segment read-only buffer"
;
return
-
1
;
return
-
1
;
}
count
=
view
.
len
;
count
=
view
.
len
;
*
p
=
view
.
buf
;
*
p
=
view
.
buf
;
PyBuffer_Release
(
&
view
);
PyBuffer_Release
(
&
view
);
return
count
;
return
count
;
}
}
/* XXX for 3.x, getbuffer and convertbuffer can probably
be merged again. */
static
int
static
int
getbuffer
(
PyObject
*
arg
,
Py_buffer
*
view
,
char
**
errmsg
)
getbuffer
(
PyObject
*
arg
,
Py_buffer
*
view
,
char
**
errmsg
)
{
{
PyBufferProcs
*
pb
=
Py_TYPE
(
arg
)
->
tp_as_buffer
;
if
(
PyObject_GetBuffer
(
arg
,
view
,
PyBUF_SIMPLE
)
!=
0
)
{
if
(
pb
==
NULL
)
{
*
errmsg
=
"bytes or buffer"
;
*
errmsg
=
"bytes or buffer"
;
return
-
1
;
return
-
1
;
}
}
if
(
pb
->
bf_getbuffer
==
NULL
)
{
*
errmsg
=
"convertible to a buffer"
;
return
-
1
;
}
if
(
PyObject_GetBuffer
(
arg
,
view
,
0
)
<
0
)
{
*
errmsg
=
"convertible to a buffer"
;
return
-
1
;
}
if
(
!
PyBuffer_IsContiguous
(
view
,
'C'
))
{
if
(
!
PyBuffer_IsContiguous
(
view
,
'C'
))
{
PyBuffer_Release
(
view
);
PyBuffer_Release
(
view
);
*
errmsg
=
"contiguous buffer"
;
*
errmsg
=
"contiguous buffer"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment