Mailinglist Archive: opensuse-commit (1903 mails)

< Previous Next >
commit python-u-msgpack-python for openSUSE:Factory
Hello community,

here is the log from the commit of package python-u-msgpack-python for
openSUSE:Factory checked in at 2019-04-19 18:36:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-u-msgpack-python (Old)
and /work/SRC/openSUSE:Factory/.python-u-msgpack-python.new.5536 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-u-msgpack-python"

Fri Apr 19 18:36:42 2019 rev:6 rq:693689 version:2.5.1

Changes:
--------
---
/work/SRC/openSUSE:Factory/python-u-msgpack-python/python-u-msgpack-python.changes
2018-12-27 00:29:07.399676255 +0100
+++
/work/SRC/openSUSE:Factory/.python-u-msgpack-python.new.5536/python-u-msgpack-python.changes
2019-04-19 18:36:43.599058483 +0200
@@ -1,0 +2,12 @@
+Fri Apr 12 09:23:15 UTC 2019 - Marketa Calabkova <mcalabkova@xxxxxxxx>
+
+- update to version 2.5.1
+ * Fix handling of naive/aware datetime objects when packing the
+ timestamp extension type.
+ * Add handling for short reads during file object unpacking.
+ * Make Ext base class a new-style object for cleaner inheritance
+ in Python 2.
+ * Improve length comparisons and instance checks for minor
+ performance improvement.
+
+-------------------------------------------------------------------

Old:
----
u-msgpack-python-2.5.0.tar.gz

New:
----
u-msgpack-python-2.5.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-u-msgpack-python.spec ++++++
--- /var/tmp/diff_new_pack.QuJmPw/_old 2019-04-19 18:36:44.915060154 +0200
+++ /var/tmp/diff_new_pack.QuJmPw/_new 2019-04-19 18:36:44.943060190 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-u-msgpack-python
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@

%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-u-msgpack-python
-Version: 2.5.0
+Version: 2.5.1
Release: 0
Summary: A MessagePack serializer and deserializer
License: MIT

++++++ u-msgpack-python-2.5.0.tar.gz -> u-msgpack-python-2.5.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/u-msgpack-python-2.5.0/PKG-INFO
new/u-msgpack-python-2.5.1/PKG-INFO
--- old/u-msgpack-python-2.5.0/PKG-INFO 2018-04-02 01:15:22.000000000 +0200
+++ new/u-msgpack-python-2.5.1/PKG-INFO 2019-03-05 01:37:45.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: u-msgpack-python
-Version: 2.5.0
+Version: 2.5.1
Summary: A portable, lightweight MessagePack serializer and deserializer
written in pure Python.
Home-page: https://github.com/vsergeev/u-msgpack-python
Author: vsergeev
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/u-msgpack-python-2.5.0/README.md
new/u-msgpack-python-2.5.1/README.md
--- old/u-msgpack-python-2.5.0/README.md 2018-04-01 02:54:55.000000000
+0200
+++ new/u-msgpack-python-2.5.1/README.md 2019-03-04 03:10:56.000000000
+0100
@@ -401,6 +401,7 @@
* Python float types are packed into the msgpack float32 or float64 format
depending on the system's `sys.float_info`
* The Python `datetime.datetime` type is packed into, and unpacked from, the
msgpack `timestamp` format
* Note that this Python type only supports microsecond resolution, while
the msgpack `timestamp` format supports nanosecond resolution. Timestamps with
finer than microsecond resolution will lose precision during unpacking. Users
may override the packing and unpacking of the msgpack `timestamp` format with a
custom type for alternate behavior.
+ * Both naive and aware timestamp are supported. Naive timestamps are
packed as if they are in the UTC timezone. Timestamps are always unpacked as
aware `datetime.datetime` objects in the UTC timezone.

## Testing

diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/u-msgpack-python-2.5.0/setup.py
new/u-msgpack-python-2.5.1/setup.py
--- old/u-msgpack-python-2.5.0/setup.py 2018-04-01 02:54:55.000000000 +0200
+++ new/u-msgpack-python-2.5.1/setup.py 2019-03-04 03:10:56.000000000 +0100
@@ -5,7 +5,7 @@

setup(
name='u-msgpack-python',
- version='2.5.0',
+ version='2.5.1',
description='A portable, lightweight MessagePack serializer and
deserializer written in pure Python.',
author='vsergeev',
author_email='v@xxxxxxxxxx',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/u-msgpack-python-2.5.0/test_umsgpack.py
new/u-msgpack-python-2.5.1/test_umsgpack.py
--- old/u-msgpack-python-2.5.0/test_umsgpack.py 2018-04-01 02:54:55.000000000
+0200
+++ new/u-msgpack-python-2.5.1/test_umsgpack.py 2019-03-04 03:10:56.000000000
+0100
@@ -319,6 +319,18 @@
["float precision double", 2.5, b"\xcb\x40\x04\x00\x00\x00\x00\x00\x00"],
]

+naive_timestamp_test_vectors = [
+ ["32-bit timestamp (naive)", datetime.datetime(2000, 1, 1, 10, 5, 2, 0,
umsgpack._utc_tzinfo),
+ b"\xd6\xff\x38\x6d\xd1\x4e",
+ datetime.datetime(2000, 1, 1, 10, 5, 2, 0, umsgpack._utc_tzinfo)],
+ ["64-bit timestamp (naive)", datetime.datetime(2200, 1, 1, 10, 5, 2, 1234,
umsgpack._utc_tzinfo),
+ b"\xd7\xff\x00\x4b\x51\x41\xb0\x9e\xa6\xce",
+ datetime.datetime(2200, 1, 1, 10, 5, 2, 1234, umsgpack._utc_tzinfo)],
+ ["96-bit timestamp (naive)", datetime.datetime(3000, 1, 1, 10, 5, 2, 1234,
umsgpack._utc_tzinfo),
+ b"\xc7\x0c\xff\x00\x12\xd4\x50\x00\x00\x00\x07\x91\x5f\x59\xce",
+ datetime.datetime(3000, 1, 1, 10, 5, 2, 1234, umsgpack._utc_tzinfo)],
+]
+
CustomType = namedtuple('CustomType', ['x', 'y', 'z'])

ext_handlers = {
@@ -540,6 +552,24 @@
packed = umsgpack.packb(obj, force_float_precision=precision)
self.assertEqual(packed, data)

+ def test_pack_naive_timestamp(self):
+ for (name, obj, data, _) in naive_timestamp_test_vectors:
+ obj_repr = repr(obj)
+ print("\t Testing %s: object %s" %
+ (name, obj_repr if len(obj_repr) < 24 else obj_repr[0:24] +
"..."))
+
+ packed = umsgpack.packb(obj)
+ self.assertEqual(packed, data)
+
+ def test_unpack_naive_timestamp(self):
+ for (name, _, data, obj) in naive_timestamp_test_vectors:
+ obj_repr = repr(obj)
+ print("\t Testing %s: object %s" %
+ (name, obj_repr if len(obj_repr) < 24 else obj_repr[0:24] +
"..."))
+
+ unpacked = umsgpack.unpackb(data)
+ self.assertEqual(unpacked, obj)
+
def test_pack_ext_override(self):
# Test overridden packing of datetime.datetime
(name, obj, data) = override_ext_handlers_test_vectors[0]
@@ -585,6 +615,30 @@
for var in exported_vars_test_vector:
self.assertTrue(var in exported_vars)

+ def test_load_short_read(self):
+ # When reading from files, the network, etc. there's no guarantee that
+ # read(n) returns n bytes. Simulate this with a file-like object that
+ # returns 1 byte at a time.
+
+ class SlowFile(object):
+ def __init__(self, data):
+ self._data = data
+
+ def read(self, n=None):
+ if n is None or len(self._data) == 0:
+ data, self._data = self._data, b''
+ return data
+
+ chunk = self._data[0:1]
+ self._data = self._data[1:]
+ return chunk
+
+ obj = {'hello': 'world'}
+ f = SlowFile(umsgpack.dumps(obj))
+ unpacked = umsgpack.load(f)
+
+ self.assertEqual(unpacked, obj)
+

if __name__ == '__main__':
unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/u-msgpack-python-2.5.0/u_msgpack_python.egg-info/PKG-INFO
new/u-msgpack-python-2.5.1/u_msgpack_python.egg-info/PKG-INFO
--- old/u-msgpack-python-2.5.0/u_msgpack_python.egg-info/PKG-INFO
2018-04-02 01:15:22.000000000 +0200
+++ new/u-msgpack-python-2.5.1/u_msgpack_python.egg-info/PKG-INFO
2019-03-05 01:37:45.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: u-msgpack-python
-Version: 2.5.0
+Version: 2.5.1
Summary: A portable, lightweight MessagePack serializer and deserializer
written in pure Python.
Home-page: https://github.com/vsergeev/u-msgpack-python
Author: vsergeev
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/u-msgpack-python-2.5.0/umsgpack.py
new/u-msgpack-python-2.5.1/umsgpack.py
--- old/u-msgpack-python-2.5.0/umsgpack.py 2018-04-01 02:54:55.000000000
+0200
+++ new/u-msgpack-python-2.5.1/umsgpack.py 2019-03-04 03:10:56.000000000
+0100
@@ -1,4 +1,4 @@
-# u-msgpack-python v2.5.0 - v at sergeev.io
+# u-msgpack-python v2.5.1 - v at sergeev.io
# https://github.com/vsergeev/u-msgpack-python
#
# u-msgpack-python is a lightweight MessagePack serializer and deserializer
@@ -31,7 +31,7 @@
# THE SOFTWARE.
#
"""
-u-msgpack-python v2.5.0 - v at sergeev.io
+u-msgpack-python v2.5.1 - v at sergeev.io
https://github.com/vsergeev/u-msgpack-python

u-msgpack-python is a lightweight MessagePack serializer and deserializer
@@ -49,10 +49,10 @@
import sys
import io

-__version__ = "2.5.0"
+__version__ = "2.5.1"
"Module version string"

-version = (2, 5, 0)
+version = (2, 5, 1)
"Module version tuple"


@@ -61,7 +61,7 @@
##############################################################################

# Extension type for application-defined types and data
-class Ext:
+class Ext(object):
"""
The Ext class facilitates creating a serializable extension object to store
an application-defined type and data byte array.
@@ -250,15 +250,15 @@
else:
raise UnsupportedTypeException("huge signed int")
else:
- if obj <= 127:
+ if obj < 128:
fp.write(struct.pack("B", obj))
- elif obj <= 2**8 - 1:
+ elif obj < 2**8:
fp.write(b"\xcc" + struct.pack("B", obj))
- elif obj <= 2**16 - 1:
+ elif obj < 2**16:
fp.write(b"\xcd" + struct.pack(">H", obj))
- elif obj <= 2**32 - 1:
+ elif obj < 2**32:
fp.write(b"\xce" + struct.pack(">I", obj))
- elif obj <= 2**64 - 1:
+ elif obj < 2**64:
fp.write(b"\xcf" + struct.pack(">Q", obj))
else:
raise UnsupportedTypeException("huge unsigned int")
@@ -285,66 +285,77 @@

def _pack_string(obj, fp, options):
obj = obj.encode('utf-8')
- if len(obj) <= 31:
- fp.write(struct.pack("B", 0xa0 | len(obj)) + obj)
- elif len(obj) <= 2**8 - 1:
- fp.write(b"\xd9" + struct.pack("B", len(obj)) + obj)
- elif len(obj) <= 2**16 - 1:
- fp.write(b"\xda" + struct.pack(">H", len(obj)) + obj)
- elif len(obj) <= 2**32 - 1:
- fp.write(b"\xdb" + struct.pack(">I", len(obj)) + obj)
+ obj_len = len(obj)
+ if obj_len < 32:
+ fp.write(struct.pack("B", 0xa0 | obj_len) + obj)
+ elif obj_len < 2**8:
+ fp.write(b"\xd9" + struct.pack("B", obj_len) + obj)
+ elif obj_len < 2**16:
+ fp.write(b"\xda" + struct.pack(">H", obj_len) + obj)
+ elif obj_len < 2**32:
+ fp.write(b"\xdb" + struct.pack(">I", obj_len) + obj)
else:
raise UnsupportedTypeException("huge string")


def _pack_binary(obj, fp, options):
- if len(obj) <= 2**8 - 1:
- fp.write(b"\xc4" + struct.pack("B", len(obj)) + obj)
- elif len(obj) <= 2**16 - 1:
- fp.write(b"\xc5" + struct.pack(">H", len(obj)) + obj)
- elif len(obj) <= 2**32 - 1:
- fp.write(b"\xc6" + struct.pack(">I", len(obj)) + obj)
+ obj_len = len(obj)
+ if obj_len < 2**8:
+ fp.write(b"\xc4" + struct.pack("B", obj_len) + obj)
+ elif obj_len < 2**16:
+ fp.write(b"\xc5" + struct.pack(">H", obj_len) + obj)
+ elif obj_len < 2**32:
+ fp.write(b"\xc6" + struct.pack(">I", obj_len) + obj)
else:
raise UnsupportedTypeException("huge binary string")


def _pack_oldspec_raw(obj, fp, options):
- if len(obj) <= 31:
- fp.write(struct.pack("B", 0xa0 | len(obj)) + obj)
- elif len(obj) <= 2**16 - 1:
- fp.write(b"\xda" + struct.pack(">H", len(obj)) + obj)
- elif len(obj) <= 2**32 - 1:
- fp.write(b"\xdb" + struct.pack(">I", len(obj)) + obj)
+ obj_len = len(obj)
+ if obj_len < 32:
+ fp.write(struct.pack("B", 0xa0 | obj_len) + obj)
+ elif obj_len < 2**16:
+ fp.write(b"\xda" + struct.pack(">H", obj_len) + obj)
+ elif obj_len < 2**32:
+ fp.write(b"\xdb" + struct.pack(">I", obj_len) + obj)
else:
raise UnsupportedTypeException("huge raw string")


def _pack_ext(obj, fp, options):
- if len(obj.data) == 1:
+ obj_len = len(obj.data)
+ if obj_len == 1:
fp.write(b"\xd4" + struct.pack("B", obj.type & 0xff) + obj.data)
- elif len(obj.data) == 2:
+ elif obj_len == 2:
fp.write(b"\xd5" + struct.pack("B", obj.type & 0xff) + obj.data)
- elif len(obj.data) == 4:
+ elif obj_len == 4:
fp.write(b"\xd6" + struct.pack("B", obj.type & 0xff) + obj.data)
- elif len(obj.data) == 8:
+ elif obj_len == 8:
fp.write(b"\xd7" + struct.pack("B", obj.type & 0xff) + obj.data)
- elif len(obj.data) == 16:
+ elif obj_len == 16:
fp.write(b"\xd8" + struct.pack("B", obj.type & 0xff) + obj.data)
- elif len(obj.data) <= 2**8 - 1:
+ elif obj_len < 2**8:
fp.write(b"\xc7" +
- struct.pack("BB", len(obj.data), obj.type & 0xff) + obj.data)
- elif len(obj.data) <= 2**16 - 1:
+ struct.pack("BB", obj_len, obj.type & 0xff) + obj.data)
+ elif obj_len < 2**16:
fp.write(b"\xc8" +
- struct.pack(">HB", len(obj.data), obj.type & 0xff) + obj.data)
- elif len(obj.data) <= 2**32 - 1:
+ struct.pack(">HB", obj_len, obj.type & 0xff) + obj.data)
+ elif obj_len < 2**32:
fp.write(b"\xc9" +
- struct.pack(">IB", len(obj.data), obj.type & 0xff) + obj.data)
+ struct.pack(">IB", obj_len, obj.type & 0xff) + obj.data)
else:
raise UnsupportedTypeException("huge ext data")


def _pack_ext_timestamp(obj, fp, options):
- delta = obj - _epoch
+ if not obj.tzinfo:
+ # Object is naive datetime, convert to aware date time,
+ # assuming UTC timezone
+ delta = obj.replace(tzinfo=_utc_tzinfo) - _epoch
+ else:
+ # Object is aware datetime
+ delta = obj - _epoch
+
seconds = delta.seconds + delta.days * 86400
microseconds = delta.microseconds

@@ -367,12 +378,13 @@


def _pack_array(obj, fp, options):
- if len(obj) <= 15:
- fp.write(struct.pack("B", 0x90 | len(obj)))
- elif len(obj) <= 2**16 - 1:
- fp.write(b"\xdc" + struct.pack(">H", len(obj)))
- elif len(obj) <= 2**32 - 1:
- fp.write(b"\xdd" + struct.pack(">I", len(obj)))
+ obj_len = len(obj)
+ if obj_len < 16:
+ fp.write(struct.pack("B", 0x90 | obj_len))
+ elif obj_len < 2**16:
+ fp.write(b"\xdc" + struct.pack(">H", obj_len))
+ elif obj_len < 2**32:
+ fp.write(b"\xdd" + struct.pack(">I", obj_len))
else:
raise UnsupportedTypeException("huge array")

@@ -381,12 +393,13 @@


def _pack_map(obj, fp, options):
- if len(obj) <= 15:
- fp.write(struct.pack("B", 0x80 | len(obj)))
- elif len(obj) <= 2**16 - 1:
- fp.write(b"\xde" + struct.pack(">H", len(obj)))
- elif len(obj) <= 2**32 - 1:
- fp.write(b"\xdf" + struct.pack(">I", len(obj)))
+ obj_len = len(obj)
+ if obj_len < 16:
+ fp.write(struct.pack("B", 0x80 | obj_len))
+ elif obj_len < 2**16:
+ fp.write(b"\xde" + struct.pack(">H", obj_len))
+ elif obj_len < 2**32:
+ fp.write(b"\xdf" + struct.pack(">I", obj_len))
else:
raise UnsupportedTypeException("huge array")

@@ -437,7 +450,7 @@
_pack_ext(ext_handlers[obj.__class__](obj), fp, options)
elif isinstance(obj, bool):
_pack_boolean(obj, fp, options)
- elif isinstance(obj, int) or isinstance(obj, long):
+ elif isinstance(obj, (int, long)):
_pack_integer(obj, fp, options)
elif isinstance(obj, float):
_pack_float(obj, fp, options)
@@ -449,7 +462,7 @@
_pack_string(obj, fp, options)
elif isinstance(obj, str):
_pack_binary(obj, fp, options)
- elif isinstance(obj, list) or isinstance(obj, tuple):
+ elif isinstance(obj, (list, tuple)):
_pack_array(obj, fp, options)
elif isinstance(obj, dict):
_pack_map(obj, fp, options)
@@ -521,7 +534,7 @@
_pack_string(obj, fp, options)
elif isinstance(obj, bytes):
_pack_binary(obj, fp, options)
- elif isinstance(obj, list) or isinstance(obj, tuple):
+ elif isinstance(obj, (list, tuple)):
_pack_array(obj, fp, options)
elif isinstance(obj, dict):
_pack_map(obj, fp, options)
@@ -613,9 +626,20 @@


def _read_except(fp, n):
+ if n == 0:
+ return b""
+
data = fp.read(n)
- if len(data) < n:
+ if len(data) == 0:
raise InsufficientDataException()
+
+ while len(data) < n:
+ chunk = fp.read(n - len(data))
+ if len(chunk) == 0:
+ raise InsufficientDataException()
+
+ data += chunk
+
return data


@@ -751,16 +775,17 @@


def _unpack_ext_timestamp(ext, options):
- if len(ext.data) == 4:
+ obj_len = len(ext.data)
+ if obj_len == 4:
# 32-bit timestamp
seconds = struct.unpack(">I", ext.data)[0]
microseconds = 0
- elif len(ext.data) == 8:
+ elif obj_len == 8:
# 64-bit timestamp
value = struct.unpack(">Q", ext.data)[0]
seconds = value & 0x3ffffffff
microseconds = (value >> 34) // 1000
- elif len(ext.data) == 12:
+ elif obj_len == 12:
# 96-bit timestamp
seconds = struct.unpack(">q", ext.data[4:12])[0]
microseconds = struct.unpack(">I", ext.data[0:4])[0] // 1000
@@ -1045,9 +1070,21 @@
if sys.version_info[0] == 3:
_utc_tzinfo = datetime.timezone.utc
else:
- _utc_tzinfo = None
+ class UTC(datetime.tzinfo):
+ ZERO = datetime.timedelta(0)
+
+ def utcoffset(self, dt):
+ return UTC.ZERO
+
+ def tzname(self, dt):
+ return "UTC"
+
+ def dst(self, dt):
+ return UTC.ZERO
+
+ _utc_tzinfo = UTC()

- # Calculate epoch datetime
+ # Calculate an aware epoch datetime
_epoch = datetime.datetime(1970, 1, 1, tzinfo=_utc_tzinfo)

# Auto-detect system float precision


< Previous Next >
This Thread
  • No further messages