Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ install:

script:
- python -c 'import sys; print(hex(sys.maxsize))'
- python -c 'from msgpack import _msgpack'
- python -c 'from msgpack import _cmsgpack'
- pytest -v test
- MSGPACK_PUREPYTHON=x pytest -v test

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all: cython

.PHONY: cython
cython:
cython --cplus msgpack/_msgpack.pyx
cython --cplus msgpack/_cmsgpack.pyx

.PHONY: test
test:
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ environment:

install:
# We need wheel installed to build wheels
- "%PYTHON%\\python.exe -m pip install -U pip"
- "%PYTHON%\\python.exe -m pip install -U cython"
- "%PYTHON%\\Scripts\\cython --cplus msgpack/_packer.pyx msgpack/_unpacker.pyx"
- "%PYTHON%\\Scripts\\cython --cplus msgpack/_cmsgpack.pyx"

build: off

Expand Down
2 changes: 1 addition & 1 deletion docker/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for V in cp36-cp36m cp35-cp35m cp27-cp27m cp27-cp27mu; do
$PYBIN/pip install pytest
pushd test # prevent importing msgpack package in current directory.
$PYBIN/python -c 'import sys; print(hex(sys.maxsize))'
$PYBIN/python -c 'from msgpack import _msgpack' # Ensure extension is available
$PYBIN/python -c 'from msgpack import _cmsgpack' # Ensure extension is available
$PYBIN/pytest -v .
popd
done
2 changes: 1 addition & 1 deletion msgpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __new__(cls, code, data):
from msgpack.fallback import Packer, unpackb, Unpacker
else:
try:
from msgpack._msgpack import Packer, unpackb, Unpacker
from msgpack._cmsgpack import Packer, unpackb, Unpacker
except ImportError:
from msgpack.fallback import Packer, unpackb, Unpacker

Expand Down
4 changes: 4 additions & 0 deletions msgpack/_cmsgpack.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# coding: utf-8
#cython: embedsignature=True, c_string_encoding=ascii, language_level=2
include "_packer.pyx"
include "_unpacker.pyx"
4 changes: 0 additions & 4 deletions msgpack/_msgpack.pyx

This file was deleted.

10 changes: 3 additions & 7 deletions msgpack/_packer.pyx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# coding: utf-8
#cython: embedsignature=True, c_string_encoding=ascii

from cpython cimport *
from cpython.version cimport PY_MAJOR_VERSION
from cpython.exc cimport PyErr_WarnEx
from cpython.bytearray cimport PyByteArray_Check, PyByteArray_CheckExact

from msgpack import ExtType


cdef extern from "Python.h":

int PyMemoryView_Check(object obj)
int PyByteArray_Check(object obj)
int PyByteArray_CheckExact(object obj)
char* PyUnicode_AsUTF8AndSize(object obj, Py_ssize_t *l) except NULL


Expand Down Expand Up @@ -204,7 +200,7 @@ cdef class Packer(object):
elif PyBytesLike_CheckExact(o) if strict_types else PyBytesLike_Check(o):
L = len(o)
if L > ITEM_LIMIT:
raise ValueError("%s is too large" % type(o).__name__)
PyErr_Format(ValueError, b"%.200s object is too large", Py_TYPE(o).tp_name)
rawval = o
ret = msgpack_pack_bin(&self.pk, L)
if ret == 0:
Expand Down Expand Up @@ -280,7 +276,7 @@ cdef class Packer(object):
default_used = 1
continue
else:
raise TypeError("can't serialize %r" % (o,))
PyErr_Format(TypeError, b"can not serialize '%.200s' object", Py_TYPE(o).tp_name)
return ret

cpdef pack(self, object obj):
Expand Down
22 changes: 1 addition & 21 deletions msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
# coding: utf-8
#cython: embedsignature=True, c_string_encoding=ascii

from cpython.version cimport PY_MAJOR_VERSION
from cpython.bytes cimport (
PyBytes_AsString,
PyBytes_FromStringAndSize,
PyBytes_Size,
)
from cpython.buffer cimport (
Py_buffer,
PyObject_CheckBuffer,
PyObject_GetBuffer,
PyBuffer_Release,
PyBuffer_IsContiguous,
PyBUF_READ,
PyBUF_SIMPLE,
PyBUF_FULL_RO,
)
from cpython.mem cimport PyMem_Malloc, PyMem_Free
from cpython.object cimport PyCallable_Check
from cpython.ref cimport Py_DECREF
from cpython.exc cimport PyErr_WarnEx
from cpython cimport *

cdef extern from "Python.h":
ctypedef struct PyObject
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def build_extension(self, ext):
if have_cython:
class Sdist(sdist):
def __init__(self, *args, **kwargs):
cythonize('msgpack/_msgpack.pyx')
cythonize('msgpack/_cmsgpack.pyx')
sdist.__init__(self, *args, **kwargs)
else:
Sdist = sdist
Expand All @@ -84,8 +84,8 @@ def __init__(self, *args, **kwargs):

ext_modules = []
if not hasattr(sys, 'pypy_version_info'):
ext_modules.append(Extension('msgpack._msgpack',
sources=['msgpack/_msgpack.cpp'],
ext_modules.append(Extension('msgpack._cmsgpack',
sources=['msgpack/_cmsgpack.cpp'],
libraries=libraries,
include_dirs=['.'],
define_macros=macros,
Expand Down