Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
95a3efd8
Commit
95a3efd8
authored
Jan 04, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bytearray.append(ch) for non-ASCII 1-char strings in Py2 and extend test
parent
6405dd9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+1
-1
tests/run/bytearraymethods.pyx
tests/run/bytearraymethods.pyx
+15
-0
No files found.
Cython/Utility/StringTools.c
View file @
95a3efd8
...
...
@@ -695,7 +695,7 @@ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyO
PyErr_SetString
(
PyExc_ValueError
,
"string must be of size 1"
);
return
-
1
;
}
ival
=
PyString_AS_STRING
(
value
)[
0
]
;
ival
=
(
unsigned
char
)
(
PyString_AS_STRING
(
value
)[
0
])
;
}
else
#endif
{
...
...
tests/run/bytearraymethods.pyx
View file @
95a3efd8
...
...
@@ -211,6 +211,21 @@ def bytearray_append(bytearray b, char c, int i, object o):
>>> print(b.decode('ascii'))
abcXxyz
>>> b = bytearray(b'abc')
>>> b = bytearray_append(b, ord('x'), ord('y'), ord('
\
\
xc3') if IS_PY3 else b'
\
\
xc3')
>>> print(b[:-1].decode('ascii'))
abcXxy
>>> print('%x' % b[-1])
c3
>>> b = bytearray(b'abc')
>>> try:
... b = bytearray_append(b, ord('x'), ord('y'), b'zz')
... except (TypeError, ValueError): pass # (Py3, Py2)
... else: print("FAIL")
>>> print(b.decode('ascii'))
abcXxy
>>> b = bytearray(b'abc')
>>> b = bytearray_append(b, -1, ord('y'), ord('z')) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
...
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