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
dc782b55
Commit
dc782b55
authored
Sep 18, 2009
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backport keyword argument support for bytearray.decode
parent
579a358e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+2
-0
Objects/bytearrayobject.c
Objects/bytearrayobject.c
+4
-3
No files found.
Lib/test/test_bytes.py
View file @
dc782b55
...
...
@@ -186,6 +186,8 @@ class BaseBytesTest(unittest.TestCase):
b
=
self
.
type2test
(
sample
,
"latin1"
)
self
.
assertRaises
(
UnicodeDecodeError
,
b
.
decode
,
"utf8"
)
self
.
assertEqual
(
b
.
decode
(
"utf8"
,
"ignore"
),
"Hello world
\
n
"
)
self
.
assertEqual
(
b
.
decode
(
errors
=
"ignore"
,
encoding
=
"utf8"
),
"Hello world
\
n
"
)
def
test_from_int
(
self
):
b
=
self
.
type2test
(
0
)
...
...
Objects/bytearrayobject.c
View file @
dc782b55
...
...
@@ -2942,12 +2942,13 @@ as well as any other name registered with codecs.register_error that is\n\
able to handle UnicodeDecodeErrors."
);
static
PyObject
*
bytearray_decode
(
PyObject
*
self
,
PyObject
*
args
)
bytearray_decode
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
const
char
*
encoding
=
NULL
;
const
char
*
errors
=
NULL
;
static
char
*
kwlist
[]
=
{
"encoding"
,
"errors"
,
0
};
if
(
!
PyArg_ParseTuple
(
args
,
"|ss:decode"
,
&
encoding
,
&
errors
))
if
(
!
PyArg_ParseTuple
AndKeywords
(
args
,
kwargs
,
"|ss:decode"
,
kwlist
,
&
encoding
,
&
errors
))
return
NULL
;
if
(
encoding
==
NULL
)
{
#ifdef Py_USING_UNICODE
...
...
@@ -3189,7 +3190,7 @@ bytearray_methods[] = {
_Py_capitalize__doc__
},
{
"center"
,
(
PyCFunction
)
stringlib_center
,
METH_VARARGS
,
center__doc__
},
{
"count"
,
(
PyCFunction
)
bytearray_count
,
METH_VARARGS
,
count__doc__
},
{
"decode"
,
(
PyCFunction
)
bytearray_decode
,
METH_VARARGS
,
decode_doc
},
{
"decode"
,
(
PyCFunction
)
bytearray_decode
,
METH_VARARGS
|
METH_KEYWORDS
,
decode_doc
},
{
"endswith"
,
(
PyCFunction
)
bytearray_endswith
,
METH_VARARGS
,
endswith__doc__
},
{
"expandtabs"
,
(
PyCFunction
)
stringlib_expandtabs
,
METH_VARARGS
,
expandtabs__doc__
},
...
...
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