diff --git a/fastb.c b/fastb.c index 9fe54af..030deaf 100644 --- a/fastb.c +++ b/fastb.c @@ -220,7 +220,7 @@ _fastb_read_pyobj_int(FILE *stream, PyObject *fallback) { static int _fastb_write_pyobj_int(FILE *stream, PyObject *pyobj, PyObject *fallback) { long l = PyInt_AS_LONG(pyobj); - if (-2147483647L <= l && l <= 2147483647L) { + if (-2147483648L <= l && l <= 2147483647L) { return _fastb_write_int(stream, l); } else { return _fastb_write_long(stream, l); @@ -235,9 +235,10 @@ _fastb_read_pyobj_long(FILE *stream, PyObject *fallback) { static int _fastb_write_pyobj_long(FILE *stream, PyObject *pyobj, PyObject *fallback) { long long l = PyLong_AsLongLong(pyobj); - if (-9223372036854775807LL <= l && l <= 9223372036854775807LL) { + if (!PyErr_Occurred() && -9223372036854775808LL <= l && l <= 9223372036854775807LL) { return _fastb_write_long(stream, l); } else { + PyErr_Clear(); return _fastb_write_pyobj_fallback(stream, pyobj, fallback); } } diff --git a/setup.py b/setup.py index 8fd0769..78dc91a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, Extension setup(name='ctypedbytes', - version='0.1.7', + version='0.1.8', description='A fast Python module for dealing with so called "typed bytes"', author='Klaas Bosteels', author_email='klaas@last.fm',