diff options
| author | INADA Naoki <inada-n@klab.com> | 2014-08-31 03:13:09 +0900 |
|---|---|---|
| committer | INADA Naoki <inada-n@klab.com> | 2014-08-31 03:13:09 +0900 |
| commit | ef3f94101aca6dd41a75c3ddc51762d9e8bb3a83 (patch) | |
| tree | 98e837b4952db3bfee7dd23bf35b15856db056fe | |
| parent | 6948dd51209f0f6be33d94fc3d44d20345ff9951 (diff) | |
| parent | 5d6481dcbb424bb91309048a395e3e9c02e64d71 (diff) | |
| download | msgpack-python-ef3f94101aca6dd41a75c3ddc51762d9e8bb3a83.tar.gz | |
Merge branch 'master' of github.com:msgpack/msgpack-python
| -rw-r--r-- | msgpack/unpack.h | 10 | ||||
| -rw-r--r-- | test/test_limits.py | 4 |
2 files changed, 3 insertions, 11 deletions
diff --git a/msgpack/unpack.h b/msgpack/unpack.h index 71142c6..24045d5 100644 --- a/msgpack/unpack.h +++ b/msgpack/unpack.h @@ -55,15 +55,7 @@ static inline int unpack_callback_uint8(unpack_user* u, uint8_t d, msgpack_unpac static inline int unpack_callback_uint32(unpack_user* u, uint32_t d, msgpack_unpack_object* o) { - PyObject *p; -#if UINT32_MAX > LONG_MAX - if (d > LONG_MAX) { - p = PyLong_FromUnsignedLong((unsigned long)d); - } else -#endif - { - p = PyInt_FromUnsignedLong((long)d); - } + PyObject *p = PyInt_FromSize_t((size_t)d); if (!p) return -1; *o = p; diff --git a/test/test_limits.py b/test/test_limits.py index da8cd2b..1cfa2d6 100644 --- a/test/test_limits.py +++ b/test/test_limits.py @@ -21,14 +21,14 @@ def test_integer(): def test_array_header(): packer = Packer() packer.pack_array_header(2**32-1) - with pytest.raises(ValueError): + with pytest.raises((OverflowError, ValueError)): packer.pack_array_header(2**32) def test_map_header(): packer = Packer() packer.pack_map_header(2**32-1) - with pytest.raises(ValueError): + with pytest.raises((OverflowError, ValueError)): packer.pack_array_header(2**32) |
