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
5cb6239f
Commit
5cb6239f
authored
Jun 06, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify getbuffer(): convertbuffer() fails anyway if bf_getbuffer is NULL
parent
7047eb73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
19 deletions
+11
-19
Python/getargs.c
Python/getargs.c
+11
-19
No files found.
Python/getargs.c
View file @
5cb6239f
...
...
@@ -1410,7 +1410,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
static
Py_ssize_t
convertbuffer
(
PyObject
*
arg
,
void
**
p
,
char
**
errmsg
)
{
PyBufferProcs
*
pb
=
arg
->
ob_type
->
tp_as_buffer
;
PyBufferProcs
*
pb
=
Py_TYPE
(
arg
)
->
tp_as_buffer
;
Py_ssize_t
count
;
Py_buffer
view
;
...
...
@@ -1438,31 +1438,23 @@ convertbuffer(PyObject *arg, void **p, char **errmsg)
static
int
getbuffer
(
PyObject
*
arg
,
Py_buffer
*
view
,
char
**
errmsg
)
{
void
*
buf
;
Py_ssize_t
count
;
PyBufferProcs
*
pb
=
arg
->
ob_type
->
tp_as_buffer
;
PyBufferProcs
*
pb
=
Py_TYPE
(
arg
)
->
tp_as_buffer
;
if
(
pb
==
NULL
)
{
*
errmsg
=
"bytes or buffer"
;
return
-
1
;
}
if
(
pb
->
bf_getbuffer
)
{
if
(
PyObject_GetBuffer
(
arg
,
view
,
0
)
<
0
)
{
*
errmsg
=
"convertible to a buffer"
;
return
-
1
;
}
if
(
!
PyBuffer_IsContiguous
(
view
,
'C'
))
{
*
errmsg
=
"contiguous buffer"
;
return
-
1
;
}
return
0
;
if
(
pb
->
bf_getbuffer
==
NULL
)
{
*
errmsg
=
"convertible to a buffer"
;
return
-
1
;
}
count
=
convertbuffer
(
arg
,
&
buf
,
errmsg
);
if
(
count
<
0
)
{
if
(
PyObject_GetBuffer
(
arg
,
view
,
0
)
<
0
)
{
*
errmsg
=
"convertible to a buffer"
;
return
count
;
return
-
1
;
}
if
(
!
PyBuffer_IsContiguous
(
view
,
'C'
))
{
*
errmsg
=
"contiguous buffer"
;
return
-
1
;
}
PyBuffer_FillInfo
(
view
,
NULL
,
buf
,
count
,
1
,
0
);
return
0
;
}
...
...
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