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
9c6b9166
Commit
9c6b9166
authored
Apr 26, 2015
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch binascii over to using the common _Py_strhex implementation for its hex
and hexlify functions. issue9951.
parent
e3f6393b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
28 deletions
+3
-28
Modules/binascii.c
Modules/binascii.c
+3
-28
No files found.
Modules/binascii.c
View file @
9c6b9166
...
...
@@ -56,6 +56,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pystrhex.h"
#ifdef USE_ZLIB_CRC32
#include "zlib.h"
#endif
...
...
@@ -1117,33 +1118,7 @@ static PyObject *
binascii_b2a_hex_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
)
/*[clinic end generated code: output=179318922c2f8fda input=96423cfa299ff3b1]*/
{
char
*
argbuf
;
Py_ssize_t
arglen
;
PyObject
*
retval
;
char
*
retbuf
;
Py_ssize_t
i
,
j
;
argbuf
=
data
->
buf
;
arglen
=
data
->
len
;
assert
(
arglen
>=
0
);
if
(
arglen
>
PY_SSIZE_T_MAX
/
2
)
return
PyErr_NoMemory
();
retval
=
PyBytes_FromStringAndSize
(
NULL
,
arglen
*
2
);
if
(
!
retval
)
return
NULL
;
retbuf
=
PyBytes_AS_STRING
(
retval
);
/* make hex version of string, taken from shamodule.c */
for
(
i
=
j
=
0
;
i
<
arglen
;
i
++
)
{
unsigned
char
c
;
c
=
(
argbuf
[
i
]
>>
4
)
&
0xf
;
retbuf
[
j
++
]
=
Py_hexdigits
[
c
];
c
=
argbuf
[
i
]
&
0xf
;
retbuf
[
j
++
]
=
Py_hexdigits
[
c
];
}
return
retval
;
return
_Py_strhex_bytes
((
const
char
*
)
data
->
buf
,
data
->
len
);
}
/*[clinic input]
...
...
@@ -1158,7 +1133,7 @@ static PyObject *
binascii_hexlify_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
)
/*[clinic end generated code: output=6098440091fb61dc input=2e3afae7f083f061]*/
{
return
binascii_b2a_hex_impl
(
module
,
data
);
return
_Py_strhex_bytes
((
const
char
*
)
data
->
buf
,
data
->
len
);
}
static
int
...
...
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