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
d70539ab
Commit
d70539ab
authored
May 09, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be more robust around bytes for e[st]#? formats.
parent
6262cc79
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
Python/getargs.c
Python/getargs.c
+8
-4
No files found.
Python/getargs.c
View file @
d70539ab
...
@@ -915,7 +915,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
...
@@ -915,7 +915,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
PyObject
*
s
;
PyObject
*
s
;
int
recode_strings
;
int
recode_strings
;
Py_ssize_t
size
;
Py_ssize_t
size
;
char
*
ptr
;
c
onst
c
har
*
ptr
;
/* Get 'e' parameter: the encoding name */
/* Get 'e' parameter: the encoding name */
encoding
=
(
const
char
*
)
va_arg
(
*
p_va
,
const
char
*
);
encoding
=
(
const
char
*
)
va_arg
(
*
p_va
,
const
char
*
);
...
@@ -941,11 +941,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
...
@@ -941,11 +941,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
arg
,
msgbuf
,
bufsize
);
arg
,
msgbuf
,
bufsize
);
/* Encode object */
/* Encode object */
if
(
!
recode_strings
&&
PyString_Check
(
arg
))
{
if
(
!
recode_strings
&&
(
PyString_Check
(
arg
)
||
PyBytes_Check
(
arg
)))
{
s
=
arg
;
s
=
arg
;
Py_INCREF
(
s
);
Py_INCREF
(
s
);
size
=
PyString_GET_SIZE
(
s
);
if
(
PyObject_AsCharBuffer
(
s
,
&
ptr
,
&
size
)
<
0
)
ptr
=
PyString_AS_STRING
(
s
);
return
converterr
(
"(AsCharBuffer failed)"
,
arg
,
msgbuf
,
bufsize
);
}
}
else
{
else
{
PyObject
*
u
;
PyObject
*
u
;
...
@@ -973,6 +975,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
...
@@ -973,6 +975,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
}
}
size
=
PyBytes_GET_SIZE
(
s
);
size
=
PyBytes_GET_SIZE
(
s
);
ptr
=
PyBytes_AS_STRING
(
s
);
ptr
=
PyBytes_AS_STRING
(
s
);
if
(
ptr
==
NULL
)
ptr
=
""
;
}
}
/* Write output; output is guaranteed to be 0-terminated */
/* Write output; output is guaranteed to be 0-terminated */
...
...
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