mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 09:50:01 +00:00
Fix error when use unicode_literal in Python 2
This commit is contained in:
parent
75ce78dd15
commit
2985f4d865
3 changed files with 40 additions and 6 deletions
|
|
@ -7,6 +7,13 @@ language: python
|
|||
python:
|
||||
- 2.7
|
||||
|
||||
env:
|
||||
- TOXENV=py26-c,py27-c
|
||||
- TOXENV=py32-c,py33-c,py34-c
|
||||
- TOXENV=py26-pure,py27-pure
|
||||
- TOXENV=py32-pure,py33-pure,py34-pure
|
||||
- TOXENV=pypy-pure,pypy3-pure
|
||||
|
||||
install:
|
||||
- pip install wheel tox
|
||||
- ls -la wheelhouse
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ cdef class Unpacker(object):
|
|||
|
||||
def __init__(self, file_like=None, Py_ssize_t read_size=0, bint use_list=1,
|
||||
object object_hook=None, object object_pairs_hook=None, object list_hook=None,
|
||||
str encoding=None, str unicode_errors='strict', int max_buffer_size=0,
|
||||
encoding=None, unicode_errors='strict', int max_buffer_size=0,
|
||||
object ext_hook=ExtType,
|
||||
Py_ssize_t max_str_len=2147483647, # 2**32-1
|
||||
Py_ssize_t max_bin_len=2147483647,
|
||||
|
|
@ -289,15 +289,19 @@ cdef class Unpacker(object):
|
|||
if encoding is not None:
|
||||
if isinstance(encoding, unicode):
|
||||
self.encoding = encoding.encode('ascii')
|
||||
else:
|
||||
elif isinstance(encoding, bytes):
|
||||
self.encoding = encoding
|
||||
else:
|
||||
raise TypeError("encoding should be bytes or unicode")
|
||||
cenc = PyBytes_AsString(self.encoding)
|
||||
|
||||
if unicode_errors is not None:
|
||||
if isinstance(unicode_errors, unicode):
|
||||
self.unicode_errors = unicode_errors.encode('ascii')
|
||||
else:
|
||||
elif isinstance(unicode_errors, bytes):
|
||||
self.unicode_errors = unicode_errors
|
||||
else:
|
||||
raise TypeError("unicode_errors should be bytes or unicode")
|
||||
cerr = PyBytes_AsString(self.unicode_errors)
|
||||
|
||||
init_ctx(&self.ctx, object_hook, object_pairs_hook, list_hook,
|
||||
|
|
|
|||
29
tox.ini
29
tox.ini
|
|
@ -1,5 +1,5 @@
|
|||
[tox]
|
||||
envlist = {py26,py27,py32,py33,py34}-{c,pure},{pypy,pypy3}-pure
|
||||
envlist = {py26,py27,py32,py33,py34}-{c,pure},{pypy,pypy3}-pure,py27-x86,py34-x86
|
||||
|
||||
[variants:pure]
|
||||
setenv=
|
||||
|
|
@ -11,6 +11,29 @@ deps=
|
|||
|
||||
changedir=test
|
||||
commands=
|
||||
c: python -c 'from msgpack import _packer, _unpacker'
|
||||
c: py.test
|
||||
c,x86: python -c 'from msgpack import _packer, _unpacker'
|
||||
c,x86: py.test
|
||||
pure: py.test
|
||||
|
||||
[testenv:py27-x86]
|
||||
basepython=python2.7-x86
|
||||
deps=
|
||||
pytest
|
||||
|
||||
changedir=test
|
||||
commands=
|
||||
python -c 'import sys; print(hex(sys.maxsize))'
|
||||
python -c 'from msgpack import _packer, _unpacker'
|
||||
py.test
|
||||
|
||||
[testenv:py34-x86]
|
||||
basepython=python3.4-x86
|
||||
deps=
|
||||
pytest
|
||||
|
||||
changedir=test
|
||||
commands=
|
||||
python -c 'import sys; print(hex(sys.maxsize))'
|
||||
python -c 'from msgpack import _packer, _unpacker'
|
||||
py.test
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue