Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b176d403
Kaydet (Commit)
b176d403
authored
Ock 20, 2015
tarafından
Zachary Ware
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23280: Fix docstrings for binascii.(un)hexlify
üst
5a494f6a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
6 deletions
+103
-6
test_binascii.py
Lib/test/test_binascii.py
+3
-1
binascii.c
Modules/binascii.c
+31
-4
binascii.c.h
Modules/clinic/binascii.c.h
+69
-1
No files found.
Lib/test/test_binascii.py
Dosyayı görüntüle @
b176d403
...
...
@@ -162,7 +162,9 @@ class BinASCIITest(unittest.TestCase):
self
.
assertRaises
(
binascii
.
Error
,
binascii
.
a2b_hex
,
t
[:
-
1
])
self
.
assertRaises
(
binascii
.
Error
,
binascii
.
a2b_hex
,
t
[:
-
1
]
+
b
'q'
)
self
.
assertEqual
(
binascii
.
hexlify
(
b
'a'
),
b
'61'
)
# Confirm that b2a_hex == hexlify and a2b_hex == unhexlify
self
.
assertEqual
(
binascii
.
hexlify
(
self
.
type2test
(
s
)),
t
)
self
.
assertEqual
(
binascii
.
unhexlify
(
self
.
type2test
(
t
)),
u
)
def
test_qp
(
self
):
# A test for SF bug 534347 (segfaults without the proper fix)
...
...
Modules/binascii.c
Dosyayı görüntüle @
b176d403
...
...
@@ -1147,6 +1147,20 @@ binascii_b2a_hex_impl(PyModuleDef *module, Py_buffer *data)
return
retval
;
}
/*[clinic input]
binascii.hexlify = binascii.b2a_hex
Hexadecimal representation of binary data.
The return value is a bytes object.
[clinic start generated code]*/
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
);
}
static
int
to_int
(
int
c
)
...
...
@@ -1221,6 +1235,21 @@ binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr)
return
NULL
;
}
/*[clinic input]
binascii.unhexlify = binascii.a2b_hex
Binary data of hexadecimal representation.
hexstr must contain an even number of hex digits (upper or lower case).
[clinic start generated code]*/
static
PyObject
*
binascii_unhexlify_impl
(
PyModuleDef
*
module
,
Py_buffer
*
hexstr
)
/*[clinic end generated code: output=17cec7544499803e input=dd8c012725f462da]*/
{
return
binascii_a2b_hex_impl
(
module
,
hexstr
);
}
static
int
table_hex
[
128
]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
...
...
@@ -1535,10 +1564,8 @@ static struct PyMethodDef binascii_module_methods[] = {
BINASCII_B2A_HQX_METHODDEF
BINASCII_A2B_HEX_METHODDEF
BINASCII_B2A_HEX_METHODDEF
{
"unhexlify"
,
(
PyCFunction
)
binascii_a2b_hex
,
METH_VARARGS
,
binascii_a2b_hex__doc__
},
{
"hexlify"
,
(
PyCFunction
)
binascii_b2a_hex
,
METH_VARARGS
,
binascii_b2a_hex__doc__
},
BINASCII_HEXLIFY_METHODDEF
BINASCII_UNHEXLIFY_METHODDEF
BINASCII_RLECODE_HQX_METHODDEF
BINASCII_RLEDECODE_HQX_METHODDEF
BINASCII_CRC_HQX_METHODDEF
...
...
Modules/clinic/binascii.c.h
Dosyayı görüntüle @
b176d403
...
...
@@ -367,6 +367,40 @@ exit:
return
return_value
;
}
PyDoc_STRVAR
(
binascii_hexlify__doc__
,
"hexlify($module, data, /)
\n
"
"--
\n
"
"
\n
"
"Hexadecimal representation of binary data.
\n
"
"
\n
"
"The return value is a bytes object."
);
#define BINASCII_HEXLIFY_METHODDEF \
{"hexlify", (PyCFunction)binascii_hexlify, METH_VARARGS, binascii_hexlify__doc__},
static
PyObject
*
binascii_hexlify_impl
(
PyModuleDef
*
module
,
Py_buffer
*
data
);
static
PyObject
*
binascii_hexlify
(
PyModuleDef
*
module
,
PyObject
*
args
)
{
PyObject
*
return_value
=
NULL
;
Py_buffer
data
=
{
NULL
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"y*:hexlify"
,
&
data
))
goto
exit
;
return_value
=
binascii_hexlify_impl
(
module
,
&
data
);
exit:
/* Cleanup for data */
if
(
data
.
obj
)
PyBuffer_Release
(
&
data
);
return
return_value
;
}
PyDoc_STRVAR
(
binascii_a2b_hex__doc__
,
"a2b_hex($module, hexstr, /)
\n
"
"--
\n
"
...
...
@@ -402,6 +436,40 @@ exit:
return
return_value
;
}
PyDoc_STRVAR
(
binascii_unhexlify__doc__
,
"unhexlify($module, hexstr, /)
\n
"
"--
\n
"
"
\n
"
"Binary data of hexadecimal representation.
\n
"
"
\n
"
"hexstr must contain an even number of hex digits (upper or lower case)."
);
#define BINASCII_UNHEXLIFY_METHODDEF \
{"unhexlify", (PyCFunction)binascii_unhexlify, METH_VARARGS, binascii_unhexlify__doc__},
static
PyObject
*
binascii_unhexlify_impl
(
PyModuleDef
*
module
,
Py_buffer
*
hexstr
);
static
PyObject
*
binascii_unhexlify
(
PyModuleDef
*
module
,
PyObject
*
args
)
{
PyObject
*
return_value
=
NULL
;
Py_buffer
hexstr
=
{
NULL
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"O&:unhexlify"
,
ascii_buffer_converter
,
&
hexstr
))
goto
exit
;
return_value
=
binascii_unhexlify_impl
(
module
,
&
hexstr
);
exit:
/* Cleanup for hexstr */
if
(
hexstr
.
obj
)
PyBuffer_Release
(
&
hexstr
);
return
return_value
;
}
PyDoc_STRVAR
(
binascii_a2b_qp__doc__
,
"a2b_qp($module, /, data, header=False)
\n
"
"--
\n
"
...
...
@@ -475,4 +543,4 @@ exit:
return
return_value
;
}
/*[clinic end generated code: output=
68e2bcc6956b6213
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
e46d29f8c9adae7e
input=a9049054013a1b77]*/
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