Hello community,

here is the log from the commit of package python-cbor2 for openSUSE:Factory 
checked in at 2020-08-21 19:16:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-cbor2 (Old)
 and      /work/SRC/openSUSE:Factory/.python-cbor2.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-cbor2"

Fri Aug 21 19:16:19 2020 rev:5 rq:828448 version:5.1.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-cbor2/python-cbor2.changes        
2020-03-30 23:06:51.592294660 +0200
+++ /work/SRC/openSUSE:Factory/.python-cbor2.new.3399/python-cbor2.changes      
2020-08-21 19:17:19.168824687 +0200
@@ -1,0 +2,7 @@
+Fri Aug 21 10:06:22 UTC 2020 - Ondřej Súkup <mimi...@gmail.com>
+
+- Update to version 5.1.2
+ * Refcount bug in C lib causing intermittent segfaults on shutdown
+ * Fractional seconds parsing in datetimes
+
+-------------------------------------------------------------------

Old:
----
  cbor2-5.1.0.tar.gz

New:
----
  cbor2-5.1.2.tar.gz

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

Other differences:
------------------
++++++ python-cbor2.spec ++++++
--- /var/tmp/diff_new_pack.W00w4S/_old  2020-08-21 19:17:25.284828299 +0200
+++ /var/tmp/diff_new_pack.W00w4S/_new  2020-08-21 19:17:25.288828301 +0200
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-cbor2
-Version:        5.1.0
+Version:        5.1.2
 Release:        0
 Summary:        Pure Python CBOR (de)serializer with extensive tag support
 License:        MIT
@@ -51,16 +51,11 @@
 
 %check
 export LANG=en_US.UTF8
-%pytest
+%pytest_arch
 
 %files %{python_files}
 %doc README.rst
 %license LICENSE.txt
-%ifpython2
-%{python_sitelib}/*
-%endif
-%ifpython3
 %{python_sitearch}/*
-%endif
 
 %changelog

++++++ cbor2-5.1.0.tar.gz -> cbor2-5.1.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/PKG-INFO new/cbor2-5.1.2/PKG-INFO
--- old/cbor2-5.1.0/PKG-INFO    2020-03-18 18:22:18.000000000 +0100
+++ new/cbor2-5.1.2/PKG-INFO    2020-07-21 18:59:46.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: cbor2
-Version: 5.1.0
+Version: 5.1.2
 Summary: Pure Python CBOR (de)serializer with extensive tag support
 Home-page: UNKNOWN
 Author: Alex Grönholm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/cbor2/decoder.py 
new/cbor2-5.1.2/cbor2/decoder.py
--- old/cbor2-5.1.0/cbor2/decoder.py    2020-03-18 18:22:03.000000000 +0100
+++ new/cbor2-5.1.2/cbor2/decoder.py    2020-07-21 18:59:30.000000000 +0200
@@ -10,7 +10,7 @@
     CBORSimpleValue, FrozenDict)
 
 timestamp_re = re.compile(r'^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)'
-                          r'(?:\.(\d+))?(?:Z|([+-]\d\d):(\d\d))$')
+                          r'(?:\.(\d{1,6})\d*)?(?:Z|([+-]\d\d):(\d\d))$')
 
 
 class CBORDecoder(object):
@@ -363,10 +363,15 @@
                 hour,
                 minute,
                 second,
-                micro,
+                secfrac,
                 offset_h,
                 offset_m,
             ) = match.groups()
+            if secfrac is None:
+                microsecond = 0
+            else:
+                microsecond = int('{:<06}'.format(secfrac))
+
             if offset_h:
                 tz = timezone(timedelta(hours=int(offset_h), 
minutes=int(offset_m)))
             else:
@@ -374,7 +379,7 @@
 
             return self.set_shareable(datetime(
                 int(year), int(month), int(day),
-                int(hour), int(minute), int(second), int(micro or 0), tz))
+                int(hour), int(minute), int(second), microsecond, tz))
         else:
             raise CBORDecodeValueError(
                 'invalid datetime string: {!r}'.format(value))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/cbor2.egg-info/PKG-INFO 
new/cbor2-5.1.2/cbor2.egg-info/PKG-INFO
--- old/cbor2-5.1.0/cbor2.egg-info/PKG-INFO     2020-03-18 18:22:18.000000000 
+0100
+++ new/cbor2-5.1.2/cbor2.egg-info/PKG-INFO     2020-07-21 18:59:46.000000000 
+0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: cbor2
-Version: 5.1.0
+Version: 5.1.2
 Summary: Pure Python CBOR (de)serializer with extensive tag support
 Home-page: UNKNOWN
 Author: Alex Grönholm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/cbor2.egg-info/top_level.txt 
new/cbor2-5.1.2/cbor2.egg-info/top_level.txt
--- old/cbor2-5.1.0/cbor2.egg-info/top_level.txt        2020-03-18 
18:22:18.000000000 +0100
+++ new/cbor2-5.1.2/cbor2.egg-info/top_level.txt        2020-07-21 
18:59:46.000000000 +0200
@@ -1 +1,2 @@
+_cbor2
 cbor2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/docs/versionhistory.rst 
new/cbor2-5.1.2/docs/versionhistory.rst
--- old/cbor2-5.1.0/docs/versionhistory.rst     2020-03-18 18:22:03.000000000 
+0100
+++ new/cbor2-5.1.2/docs/versionhistory.rst     2020-07-21 18:59:30.000000000 
+0200
@@ -5,6 +5,18 @@
 
 This library adheres to `Semantic Versioning <http://semver.org/>`_.
 
+
+**5.1.2** (2020-07-21)
+
+- Bugfix: Refcount bug in C lib causing intermittent segfaults on shutdown 
(tdryer)
+
+**5.1.1** (2020-07-03)
+
+- Build system: Making C lib optional if it fails to compile (chiefnoah)
+- Build system: Better Glibc version detection (Sekenre and JayH5)
+- Tests: Positive and negative bignums (kalcutter)
+- Bugfix: Fractional seconds parsing in datetimes (kalcutter) 
+
 **5.1.0** (2020-03-18)
 
 - Minor API change :class:`CBORSimpleValue` is now a subclass of namedtuple 
and allows
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/setup.py new/cbor2-5.1.2/setup.py
--- old/cbor2-5.1.0/setup.py    2020-03-18 18:22:03.000000000 +0100
+++ new/cbor2-5.1.2/setup.py    2020-07-21 18:59:30.000000000 +0200
@@ -1,27 +1,42 @@
 import sys
+import os
 import platform
 from pkg_resources import parse_version
 from setuptools import setup, Extension
 
+min_glibc = parse_version('2.9')
+
+
+def check_libc():
+    "check that if we have glibc < 2.9 we should not build c ext"
+    # Borrowed from pip internals
+    # 
https://github.com/pypa/pip/blob/20.1.1/src/pip/_internal/utils/glibc.py#L21-L36
+    try:
+        # os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17":
+        libc, version = os.confstr("CS_GNU_LIBC_VERSION").split()
+    except (AttributeError, OSError, ValueError):
+        # os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
+        return True
+    if libc != 'glibc':
+        # Attempt to build with musl or other libc
+        return True
+    return parse_version(version) >= min_glibc
+
+
 cpython = platform.python_implementation() == 'CPython'
-is_glibc = platform.libc_ver()[0] == 'glibc'
 windows = sys.platform.startswith('win')
-if is_glibc:
-    glibc_ver = platform.libc_ver()[1]
-    libc_ok = parse_version(glibc_ver) >= parse_version('2.9')
-else:
-    libc_ok = not windows
-min_win_version = windows and sys.version_info >= (3, 5)
-min_unix_version = not windows and sys.version_info >= (3, 3)
+min_win_version = sys.version_info >= (3, 5)
+min_unix_version = sys.version_info >= (3, 3)
+build_c_ext = cpython and ((windows and min_win_version) or (check_libc() and 
min_unix_version))
 
 # Enable GNU features for libc's like musl, should have no effect
 # on Apple/BSDs
-if libc_ok:
+if build_c_ext and not windows:
     gnu_flag = ['-D_GNU_SOURCE']
 else:
     gnu_flag = []
 
-if cpython and ((min_unix_version and libc_ok) or min_win_version):
+if build_c_ext:
     _cbor2 = Extension(
         '_cbor2',
         # math.h routines are built-in to MSVCRT
@@ -33,7 +48,8 @@
             'source/decoder.c',
             'source/tags.c',
             'source/halffloat.c',
-        ]
+        ],
+        optional=True
     )
     kwargs = {'ext_modules': [_cbor2]}
 else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/source/decoder.c 
new/cbor2-5.1.2/source/decoder.c
--- old/cbor2-5.1.0/source/decoder.c    2020-03-18 18:22:03.000000000 +0100
+++ new/cbor2-5.1.2/source/decoder.c    2020-07-21 18:59:30.000000000 +0200
@@ -921,17 +921,15 @@
         H = strtoul(buf + 11, NULL, 10);
         M = strtoul(buf + 14, NULL, 10);
         S = strtoul(buf + 17, &p, 10);
+        uS = 0;
         if (*p == '.') {
-            uS = strtoul(buf + 20, &p, 10);
-            switch (p - (buf + 20)) {
-                case 1: uS *= 100000; break;
-                case 2: uS *= 10000; break;
-                case 3: uS *= 1000; break;
-                case 4: uS *= 100; break;
-                case 5: uS *= 10; break;
+            unsigned long int scale = 100000;
+            p++;
+            while (*p >= '0' && *p <= '9') {
+                uS += (*p++ - '0') * scale;
+                scale /= 10;
             }
-        } else
-            uS = 0;
+        }
         if (*p == 'Z') {
             offset_sign = false;
             Py_INCREF(_CBOR2_timezone_utc);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/source/module.c 
new/cbor2-5.1.2/source/module.c
--- old/cbor2-5.1.0/source/module.c     2020-03-18 18:22:03.000000000 +0100
+++ new/cbor2-5.1.2/source/module.c     2020-07-21 18:59:30.000000000 +0200
@@ -806,6 +806,7 @@
             "_cbor2.CBORError", _cbor2_CBORError__doc__, NULL, NULL);
     if (!_CBOR2_CBORError)
         goto error;
+    Py_INCREF(_CBOR2_CBORError);
     if (PyModule_AddObject(module, "CBORError", _CBOR2_CBORError) == -1)
         goto error;
 
@@ -814,6 +815,7 @@
             _CBOR2_CBORError, NULL);
     if (!_CBOR2_CBOREncodeError)
         goto error;
+    Py_INCREF(_CBOR2_CBOREncodeError);
     if (PyModule_AddObject(module, "CBOREncodeError", _CBOR2_CBOREncodeError) 
== -1)
         goto error;
 
@@ -824,6 +826,7 @@
     Py_DECREF(base);
     if (!_CBOR2_CBOREncodeTypeError)
         goto error;
+    Py_INCREF(_CBOR2_CBOREncodeTypeError);
     if (PyModule_AddObject(module, "CBOREncodeTypeError", 
_CBOR2_CBOREncodeTypeError) == -1)
         goto error;
 
@@ -834,6 +837,7 @@
     Py_DECREF(base);
     if (!_CBOR2_CBOREncodeValueError)
         goto error;
+    Py_INCREF(_CBOR2_CBOREncodeValueError);
     if (PyModule_AddObject(module, "CBOREncodeValueError", 
_CBOR2_CBOREncodeValueError) == -1)
         goto error;
 
@@ -842,6 +846,7 @@
             _CBOR2_CBORError, NULL);
     if (!_CBOR2_CBORDecodeError)
         goto error;
+    Py_INCREF(_CBOR2_CBORDecodeError);
     if (PyModule_AddObject(module, "CBORDecodeError", _CBOR2_CBORDecodeError) 
== -1)
         goto error;
 
@@ -852,6 +857,7 @@
     Py_DECREF(base);
     if (!_CBOR2_CBORDecodeValueError)
         goto error;
+    Py_INCREF(_CBOR2_CBORDecodeValueError);
     if (PyModule_AddObject(module, "CBORDecodeValueError", 
_CBOR2_CBORDecodeValueError) == -1)
         goto error;
 
@@ -862,6 +868,7 @@
     Py_DECREF(base);
     if (!_CBOR2_CBORDecodeEOF)
         goto error;
+    Py_INCREF(_CBOR2_CBORDecodeEOF);
     if (PyModule_AddObject(module, "CBORDecodeEOF", _CBOR2_CBORDecodeEOF) == 
-1)
         goto error;
 
@@ -955,7 +962,7 @@
             !(_CBOR2_str_datestr_re = PyUnicode_InternFromString(
                     "^(\\d{4})-(\\d\\d)-(\\d\\d)T"     // Y-m-d
                     "(\\d\\d):(\\d\\d):(\\d\\d)"       // H:M:S
-                    "(?:\\.(\\d+))?"                   // .uS
+                    "(?:\\.(\\d{1,6})\\d*)?"           // .uS
                     "(?:Z|([+-]\\d\\d):(\\d\\d))$")))  // +-TZ
         goto error;
     if (!_CBOR2_empty_bytes &&
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cbor2-5.1.0/tests/test_decoder.py 
new/cbor2-5.1.2/tests/test_decoder.py
--- old/cbor2-5.1.0/tests/test_decoder.py       2020-03-18 18:22:03.000000000 
+0100
+++ new/cbor2-5.1.2/tests/test_decoder.py       2020-07-21 18:59:30.000000000 
+0200
@@ -324,11 +324,73 @@
     assert decoded == expected
 
 
+def test_datetime_secfrac(impl):
+    decoded = impl.loads(b'\xc0\x78\x162018-08-02T07:00:59.1Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 100000, 
tzinfo=timezone.utc)
+    decoded = impl.loads(b'\xc0\x78\x172018-08-02T07:00:59.01Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 10000, 
tzinfo=timezone.utc)
+    decoded = impl.loads(b'\xc0\x78\x182018-08-02T07:00:59.001Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 1000, tzinfo=timezone.utc)
+    decoded = impl.loads(b'\xc0\x78\x192018-08-02T07:00:59.0001Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 100, tzinfo=timezone.utc)
+    decoded = impl.loads(b'\xc0\x78\x1a2018-08-02T07:00:59.00001Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 10, tzinfo=timezone.utc)
+    decoded = impl.loads(b'\xc0\x78\x1b2018-08-02T07:00:59.000001Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 1, tzinfo=timezone.utc)
+    decoded = impl.loads(b'\xc0\x78\x1c2018-08-02T07:00:59.0000001Z')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 0, tzinfo=timezone.utc)
+
+
+def test_datetime_secfrac_naive_float_to_int_cast(impl):
+    # A secfrac that would have rounding errors if naively parsed as
+    # `int(float(secfrac) * 1000000)`.
+    decoded = impl.loads(b'\xc0\x78\x202018-08-02T07:00:59.000251+00:00')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 251, tzinfo=timezone.utc)
+
+
+def test_datetime_secfrac_overflow(impl):
+    decoded = 
impl.loads(b'\xc0\x78\x2c2018-08-02T07:00:59.100500999999999999+00:00')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 100500, 
tzinfo=timezone.utc)
+    decoded = 
impl.loads(b'\xc0\x78\x2c2018-08-02T07:00:59.999999999999999999+00:00')
+    assert decoded == datetime(2018, 8, 2, 7, 0, 59, 999999, 
tzinfo=timezone.utc)
+
+
+def test_datetime_secfrac_requires_digit(impl):
+    with pytest.raises(impl.CBORDecodeError) as excinfo:
+        impl.loads(b'\xc0\x78\x1a2018-08-02T07:00:59.+00:00')
+    assert isinstance(excinfo.value, ValueError)
+    if sys.version_info < (3,):
+        assert str(excinfo.value) == "invalid datetime string: 
u'2018-08-02T07:00:59.+00:00'"
+    else:
+        assert str(excinfo.value) == "invalid datetime string: 
'2018-08-02T07:00:59.+00:00'"
+    with pytest.raises(impl.CBORDecodeError) as excinfo:
+        impl.loads(b'\xc0\x78\x152018-08-02T07:00:59.Z')
+    assert isinstance(excinfo.value, ValueError)
+    if sys.version_info < (3,):
+        assert str(excinfo.value) == "invalid datetime string: 
u'2018-08-02T07:00:59.Z'"
+    else:
+        assert str(excinfo.value) == "invalid datetime string: 
'2018-08-02T07:00:59.Z'"
+
+
 def test_bad_datetime(impl):
-    with pytest.raises(impl.CBORDecodeError) as exc:
+    with pytest.raises(impl.CBORDecodeError) as excinfo:
         impl.loads(unhexlify('c06b303030302d3132332d3031'))
-        assert str(exc.value).endswith("invalid datetime string: 
'0000-123-01'")
-        assert isinstance(exc, ValueError)
+    assert isinstance(excinfo.value, ValueError)
+    if sys.version_info < (3,):
+        assert str(excinfo.value) == "invalid datetime string: u'0000-123-01'"
+    else:
+        assert str(excinfo.value) == "invalid datetime string: '0000-123-01'"
+
+
+def test_positive_bignum(impl):
+    # Example from RFC 7049 section 3.4.3.
+    decoded = impl.loads(unhexlify('c249010000000000000000'))
+    assert decoded == 18446744073709551616
+
+
+def test_negative_bignum(impl):
+    decoded = impl.loads(unhexlify('c349010000000000000000'))
+    assert decoded == -18446744073709551617
 
 
 def test_fraction(impl):


Reply via email to