Hello community, here is the log from the commit of package python3-amqp for openSUSE:Factory checked in at 2017-03-03 17:46:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-amqp (Old) and /work/SRC/openSUSE:Factory/.python3-amqp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-amqp" Fri Mar 3 17:46:23 2017 rev:14 rq:461376 version:2.1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python3-amqp/python3-amqp-doc.changes 2016-12-19 11:28:20.182271920 +0100 +++ /work/SRC/openSUSE:Factory/.python3-amqp.new/python3-amqp-doc.changes 2017-03-03 17:46:24.453252066 +0100 @@ -1,0 +2,9 @@ +Wed Mar 1 15:51:23 UTC 2017 - [email protected] + +- update to version 2.1.4 + - Removes byte string comparison warnings when running under ``python -b``. + - Linux version parsing broke when the version included a '+' character + (Issue #119). + - Now sets default TCP settings for platforms that support them (e.g. Linux). + +------------------------------------------------------------------- --- /work/SRC/openSUSE:Factory/python3-amqp/python3-amqp.changes 2016-12-19 11:28:20.214267393 +0100 +++ /work/SRC/openSUSE:Factory/.python3-amqp.new/python3-amqp.changes 2017-03-03 17:46:24.529241326 +0100 @@ -1,0 +2,9 @@ +Wed Mar 1 15:51:23 UTC 2017 - [email protected] + +- update to version 2.1.4 + - Removes byte string comparison warnings when running under ``python -b``. + - Linux version parsing broke when the version included a '+' character + (Issue #119). + - Now sets default TCP settings for platforms that support them (e.g. Linux). + +------------------------------------------------------------------- Old: ---- amqp-2.1.3.tar.gz New: ---- amqp-2.1.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-amqp-doc.spec ++++++ --- /var/tmp/diff_new_pack.E8Edyi/_old 2017-03-03 17:46:25.393119240 +0100 +++ /var/tmp/diff_new_pack.E8Edyi/_new 2017-03-03 17:46:25.393119240 +0100 @@ -1,7 +1,7 @@ # # spec file for package python3-amqp-doc # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 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 @@ -17,7 +17,7 @@ Name: python3-amqp-doc -Version: 2.1.3 +Version: 2.1.4 Release: 0 Summary: Documentation for python3-amqp License: BSD-3-Clause python3-amqp.spec: same change ++++++ amqp-2.1.3.tar.gz -> amqp-2.1.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/Changelog new/amqp-2.1.4/Changelog --- old/amqp-2.1.3/Changelog 2016-12-08 02:46:38.000000000 +0100 +++ new/amqp-2.1.4/Changelog 2016-12-15 00:50:09.000000000 +0100 @@ -5,11 +5,43 @@ The previous amqplib changelog is here: http://code.google.com/p/py-amqplib/source/browse/CHANGES +.. _version-2.1.4: + +2.1.4 +===== +:release-date: 2016-12-14 03:40 P.M PST +:release-by: Ask Solem + +- Removes byte string comparison warnings when running under ``python -b``. + + Fix contributed by **Jon Dufresne**. + +- Linux version parsing broke when the version included a '+' character + (Issue #119). + +- Now sets default TCP settings for platforms that support them (e.g. Linux). + + +----------------------+---------------+ + | Constant | Value | + +======================+===============+ + | ``TCP_KEEPIDLE`` | ``60`` | + +----------------------+---------------+ + | ``TCP_KEEPINTVL`` | ``10`` | + +----------------------+---------------+ + | ``TCP_KEEPCNT`` | ``9`` | + +----------------------+---------------+ + | ``TCP_USER_TIMEOUT`` | ``1000`` (1s) | + +----------------------+---------------+ + + This will help detecting the socket being closed earlier, which is very + important in failover and load balancing scenarios. + .. _version-2.1.3: 2.1.3 ===== :release-date: 2016-12-07 06:00 P.M PST +:release-by: Ask Solem - Fixes compatibility with Python 2.7.5 and below (Issue #107). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/PKG-INFO new/amqp-2.1.4/PKG-INFO --- old/amqp-2.1.3/PKG-INFO 2016-12-08 02:51:12.000000000 +0100 +++ new/amqp-2.1.4/PKG-INFO 2016-12-15 00:52:11.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: amqp -Version: 2.1.3 +Version: 2.1.4 Summary: Low-level AMQP client for Python (fork of amqplib). Home-page: http://github.com/celery/py-amqp Author: Ask Solem @@ -12,7 +12,7 @@ |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| - :Version: 2.1.3 + :Version: 2.1.4 :Web: https://amqp.readthedocs.io/ :Download: http://pypi.python.org/pypi/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/README.rst new/amqp-2.1.4/README.rst --- old/amqp-2.1.3/README.rst 2016-12-08 02:46:53.000000000 +0100 +++ new/amqp-2.1.4/README.rst 2016-12-15 00:51:26.000000000 +0100 @@ -4,7 +4,7 @@ |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| -:Version: 2.1.3 +:Version: 2.1.4 :Web: https://amqp.readthedocs.io/ :Download: http://pypi.python.org/pypi/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp/__init__.py new/amqp-2.1.4/amqp/__init__.py --- old/amqp-2.1.3/amqp/__init__.py 2016-12-08 02:46:53.000000000 +0100 +++ new/amqp-2.1.4/amqp/__init__.py 2016-12-15 00:51:26.000000000 +0100 @@ -20,7 +20,7 @@ from collections import namedtuple -__version__ = '2.1.3' +__version__ = '2.1.4' __author__ = 'Barry Pederson' __maintainer__ = 'Ask Solem' __contact__ = '[email protected]' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp/exceptions.py new/amqp-2.1.4/amqp/exceptions.py --- old/amqp-2.1.3/amqp/exceptions.py 2016-12-08 02:40:07.000000000 +0100 +++ new/amqp-2.1.4/amqp/exceptions.py 2016-12-15 00:00:59.000000000 +0100 @@ -15,10 +15,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 from __future__ import absolute_import, unicode_literals - -from struct import pack, unpack - from .five import python_2_unicode_compatible +from .platform import pack, unpack __all__ = [ 'AMQPError', @@ -296,5 +294,5 @@ for _method_id, _method_name in list(METHOD_NAME_MAP.items()): - METHOD_NAME_MAP[unpack(b'>I', pack(b'>HH', *_method_id))[0]] = \ + METHOD_NAME_MAP[unpack('>I', pack('>HH', *_method_id))[0]] = \ _method_name diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp/method_framing.py new/amqp-2.1.4/amqp/method_framing.py --- old/amqp-2.1.3/amqp/method_framing.py 2016-12-08 02:44:44.000000000 +0100 +++ new/amqp-2.1.4/amqp/method_framing.py 2016-12-14 23:53:58.000000000 +0100 @@ -17,12 +17,12 @@ from __future__ import absolute_import, unicode_literals from collections import defaultdict -from struct import pack, unpack_from, pack_into from . import spec from .basic_message import Message from .exceptions import UnexpectedFrame from .five import range +from .platform import pack, unpack_from, pack_into from .utils import str_to_bytes __all__ = ['frame_handler', 'frame_writer'] @@ -56,7 +56,7 @@ frame_type, expected_types[channel]), ) elif frame_type == 1: - method_sig = unpack_from(b'>HH', buf, 0) + method_sig = unpack_from('>HH', buf, 0) if method_sig in content_methods: # Save what we've got so far and wait for the content-header @@ -126,48 +126,48 @@ if bigbody: # ## SLOW: string copy and write for every frame - frame = (b''.join([pack(b'>HH', *method_sig), args]) + frame = (b''.join([pack('>HH', *method_sig), args]) if type_ == 1 else b'') # encode method frame framelen = len(frame) - write(pack((str('>BHI%dsB') % framelen).encode(), + write(pack('>BHI%dsB' % framelen, type_, channel, framelen, frame, 0xce)) if body: frame = b''.join([ - pack(b'>HHQ', method_sig[0], 0, len(body)), + pack('>HHQ', method_sig[0], 0, len(body)), properties, ]) framelen = len(frame) - write(pack((str('>BHI%dsB') % framelen).encode(), + write(pack('>BHI%dsB' % framelen, 2, channel, framelen, frame, 0xce)) for i in range(0, bodylen, chunk_size): frame = body[i:i + chunk_size] framelen = len(frame) - write(pack((str('>BHI%dsB') % framelen).encode(), + write(pack('>BHI%dsB' % framelen, 3, channel, framelen, str_to_bytes(frame), 0xce)) else: # ## FAST: pack into buffer and single write - frame = (b''.join([pack(b'>HH', *method_sig), args]) + frame = (b''.join([pack('>HH', *method_sig), args]) if type_ == 1 else b'') framelen = len(frame) - pack_into((str('>BHI%dsB') % framelen).encode(), buf, offset, + pack_into('>BHI%dsB' % framelen, buf, offset, type_, channel, framelen, frame, 0xce) offset += 8 + framelen if body: frame = b''.join([ - pack(b'>HHQ', method_sig[0], 0, len(body)), + pack('>HHQ', method_sig[0], 0, len(body)), properties, ]) framelen = len(frame) - pack_into((str('>BHI%dsB') % framelen).encode(), buf, offset, + pack_into('>BHI%dsB' % framelen, buf, offset, 2, channel, framelen, frame, 0xce) offset += 8 + framelen framelen = len(body) - pack_into((str('>BHI%dsB') % framelen).encode(), buf, offset, + pack_into('>BHI%dsB' % framelen, buf, offset, 3, channel, framelen, str_to_bytes(body), 0xce) offset += 8 + framelen diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp/platform.py new/amqp-2.1.4/amqp/platform.py --- old/amqp-2.1.3/amqp/platform.py 2016-12-07 23:14:50.000000000 +0100 +++ new/amqp-2.1.4/amqp/platform.py 2016-12-15 00:02:33.000000000 +0100 @@ -1,8 +1,10 @@ """Platform compatibility.""" from __future__ import absolute_import, unicode_literals +import struct import sys import platform +import re # Jython does not have this attribute try: @@ -10,10 +12,26 @@ except ImportError: # pragma: no cover from socket import IPPROTO_TCP as SOL_TCP # noqa + +RE_NUM = re.compile(r'(\d+).+') + + +def _linux_version_to_tuple(s): + # type: (str) -> Tuple[int, int, int] + return tuple(map(_versionatom, s.split('.')[:3])) + + +def _versionatom(s): + # type: (str) -> int + if s.isdigit(): + return int(s) + match = RE_NUM.match(s) + return int(match.groups()[0]) if match else 0 + + LINUX_VERSION = None if sys.platform.startswith('linux'): - LINUX_VERSION = tuple(map( - int, platform.release().split('-')[0].split('.'))) + LINUX_VERSION = _linux_version_to_tuple(platform.release()) try: from socket import TCP_USER_TIMEOUT @@ -23,9 +41,33 @@ TCP_USER_TIMEOUT = 18 HAS_TCP_USER_TIMEOUT = LINUX_VERSION and LINUX_VERSION >= (2, 6, 37) + +if sys.version_info < (2, 7, 6): + import functools + + def _to_bytes_arg(fun): + @functools.wraps(fun) + def _inner(s, *args, **kwargs): + return fun(s.encode(), *args, **kwargs) + return _inner + + pack = _to_bytes_arg(struct.pack) + pack_into = _to_bytes_arg(struct.pack_into) + unpack = _to_bytes_arg(struct.unpack) + unpack_from = _to_bytes_arg(struct.unpack_from) +else: + pack = struct.pack + pack_into = struct.pack_into + unpack = struct.unpack + unpack_from = struct.unpack_from + __all__ = [ 'LINUX_VERSION', 'SOL_TCP', 'TCP_USER_TIMEOUT', 'HAS_TCP_USER_TIMEOUT', + 'pack', + 'pack_into', + 'unpack', + 'unpack_from', ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp/serialization.py new/amqp-2.1.4/amqp/serialization.py --- old/amqp-2.1.3/amqp/serialization.py 2016-12-08 02:40:07.000000000 +0100 +++ new/amqp-2.1.4/amqp/serialization.py 2016-12-14 23:56:26.000000000 +0100 @@ -26,11 +26,11 @@ from datetime import datetime from decimal import Decimal from io import BytesIO -from struct import pack, unpack_from from .spec import Basic from .exceptions import FrameSyntaxError from .five import int_types, long_t, string, string_t, items +from .platform import pack, unpack_from from .utils import bytes_to_str as pstr_t, str_to_bytes ftype_t = chr if sys.version_info[0] == 3 else None @@ -54,78 +54,78 @@ # 'S': long string if ftype == 'S': - slen, = unpack_from(b'>I', buf, offset) + slen, = unpack_from('>I', buf, offset) offset += 4 val = pstr_t(buf[offset:offset + slen]) offset += slen # 's': short string elif ftype == 's': - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 val = pstr_t(buf[offset:offset + slen]) offset += slen # 'b': short-short int elif ftype == 'b': - val, = unpack_from(b'>B', buf, offset) + val, = unpack_from('>B', buf, offset) offset += 1 # 'B': short-short unsigned int elif ftype == 'B': - val, = unpack_from(b'>b', buf, offset) + val, = unpack_from('>b', buf, offset) offset += 1 # 'U': short int elif ftype == 'U': - val, = unpack_from(b'>h', buf, offset) + val, = unpack_from('>h', buf, offset) offset += 2 # 'u': short unsigned int elif ftype == 'u': - val, = unpack_from(b'>H', buf, offset) + val, = unpack_from('>H', buf, offset) offset += 2 # 'I': long int elif ftype == 'I': - val, = unpack_from(b'>i', buf, offset) + val, = unpack_from('>i', buf, offset) offset += 4 # 'i': long unsigned int elif ftype == 'i': - val, = unpack_from(b'>I', buf, offset) + val, = unpack_from('>I', buf, offset) offset += 4 # 'L': long long int elif ftype == 'L': - val, = unpack_from(b'>q', buf, offset) + val, = unpack_from('>q', buf, offset) offset += 8 # 'l': long long unsigned int elif ftype == 'l': - val, = unpack_from(b'>Q', buf, offset) + val, = unpack_from('>Q', buf, offset) offset += 8 # 'f': float elif ftype == 'f': - val, = unpack_from(b'>f', buf, offset) + val, = unpack_from('>f', buf, offset) offset += 4 # 'd': double elif ftype == 'd': - val, = unpack_from(b'>d', buf, offset) + val, = unpack_from('>d', buf, offset) offset += 8 # 'D': decimal elif ftype == 'D': - d, = unpack_from(b'>B', buf, offset) + d, = unpack_from('>B', buf, offset) offset += 1 - n, = unpack_from(b'>i', buf, offset) + n, = unpack_from('>i', buf, offset) offset += 4 val = Decimal(n) / Decimal(10 ** d) # 'F': table elif ftype == 'F': - tlen, = unpack_from(b'>I', buf, offset) + tlen, = unpack_from('>I', buf, offset) offset += 4 limit = offset + tlen val = {} while offset < limit: - keylen, = unpack_from(b'>B', buf, offset) + keylen, = unpack_from('>B', buf, offset) offset += 1 key = pstr_t(buf[offset:offset + keylen]) offset += keylen val[key], offset = _read_item(buf, offset) # 'A': array elif ftype == 'A': - alen, = unpack_from(b'>I', buf, offset) + alen, = unpack_from('>I', buf, offset) offset += 4 limit = offset + alen val = [] @@ -134,12 +134,12 @@ val.append(v) # 't' (bool) elif ftype == 't': - val, = unpack_from(b'>B', buf, offset) + val, = unpack_from('>B', buf, offset) val = bool(val) offset += 1 # 'T': timestamp elif ftype == 'T': - val, = unpack_from(b'>Q', buf, offset) + val, = unpack_from('>Q', buf, offset) offset += 8 val = datetime.utcfromtimestamp(val) # 'V': void @@ -186,51 +186,51 @@ offset += 1 elif p == 'o': bitcount = bits = 0 - val, = unpack_from(b'>B', buf, offset) + val, = unpack_from('>B', buf, offset) offset += 1 elif p == 'B': bitcount = bits = 0 - val, = unpack_from(b'>H', buf, offset) + val, = unpack_from('>H', buf, offset) offset += 2 elif p == 'l': bitcount = bits = 0 - val, = unpack_from(b'>I', buf, offset) + val, = unpack_from('>I', buf, offset) offset += 4 elif p == 'L': bitcount = bits = 0 - val, = unpack_from(b'>Q', buf, offset) + val, = unpack_from('>Q', buf, offset) offset += 8 elif p == 'f': bitcount = bits = 0 - val, = unpack_from(b'>f', buf, offset) + val, = unpack_from('>f', buf, offset) offset += 4 elif p == 's': bitcount = bits = 0 - slen, = unpack_from(b'B', buf, offset) + slen, = unpack_from('B', buf, offset) offset += 1 val = buf[offset:offset + slen].decode('utf-8') offset += slen elif p == 'S': bitcount = bits = 0 - slen, = unpack_from(b'>I', buf, offset) + slen, = unpack_from('>I', buf, offset) offset += 4 val = buf[offset:offset + slen].decode('utf-8') offset += slen elif p == 'F': bitcount = bits = 0 - tlen, = unpack_from(b'>I', buf, offset) + tlen, = unpack_from('>I', buf, offset) offset += 4 limit = offset + tlen val = {} while offset < limit: - keylen, = unpack_from(b'>B', buf, offset) + keylen, = unpack_from('>B', buf, offset) offset += 1 key = pstr_t(buf[offset:offset + keylen]) offset += keylen val[key], offset = _read_item(buf, offset) elif p == 'A': bitcount = bits = 0 - alen, = unpack_from(b'>I', buf, offset) + alen, = unpack_from('>I', buf, offset) offset += 4 limit = offset + alen val = [] @@ -239,7 +239,7 @@ val.append(aval) elif p == 'T': bitcount = bits = 0 - val, = unpack_from(b'>Q', buf, offset) + val, = unpack_from('>Q', buf, offset) offset += 8 val = datetime.utcfromtimestamp(val) else: @@ -250,7 +250,7 @@ def _flushbits(bits, write, pack=pack): if bits: - write(pack(b'B' * len(bits), *bits)) + write(pack('B' * len(bits), *bits)) bits[:] = [] return 0 @@ -287,32 +287,32 @@ bitcount += 1 elif p == 'o': bitcount = _flushbits(bits, write) - write(pack(b'B', val)) + write(pack('B', val)) elif p == 'B': bitcount = _flushbits(bits, write) - write(pack(b'>H', int(val))) + write(pack('>H', int(val))) elif p == 'l': bitcount = _flushbits(bits, write) - write(pack(b'>I', val)) + write(pack('>I', val)) elif p == 'L': bitcount = _flushbits(bits, write) - write(pack(b'>Q', val)) + write(pack('>Q', val)) elif p == 'f': bitcount = _flushbits(bits, write) - write(pack(b'>f', val)) + write(pack('>f', val)) elif p == 's': val = val or '' bitcount = _flushbits(bits, write) if isinstance(val, string): val = val.encode('utf-8') - write(pack(b'B', len(val))) + write(pack('B', len(val))) write(val) elif p == 'S': val = val or '' bitcount = _flushbits(bits, write) if isinstance(val, string): val = val.encode('utf-8') - write(pack(b'>I', len(val))) + write(pack('>I', len(val))) write(val) elif p == 'F': bitcount = _flushbits(bits, write) @@ -321,7 +321,7 @@ bitcount = _flushbits(bits, write) _write_array(val or [], write, bits) elif p == 'T': - write(pack(b'>Q', long_t(calendar.timegm(val.utctimetuple())))) + write(pack('>Q', long_t(calendar.timegm(val.utctimetuple())))) _flushbits(bits, write) return out.getvalue() @@ -333,7 +333,7 @@ for k, v in items(d): if isinstance(k, string): k = k.encode('utf-8') - twrite(pack(b'B', len(k))) + twrite(pack('B', len(k))) twrite(k) try: _write_item(v, twrite, bits) @@ -341,7 +341,7 @@ raise FrameSyntaxError( ILLEGAL_TABLE_TYPE_WITH_KEY.format(type(v), k, v)) table_data = out.getvalue() - write(pack(b'>I', len(table_data))) + write(pack('>I', len(table_data))) write(table_data) @@ -355,7 +355,7 @@ raise FrameSyntaxError( ILLEGAL_TABLE_TYPE_WITH_VALUE.format(type(v), v)) array_data = out.getvalue() - write(pack(b'>I', len(array_data))) + write(pack('>I', len(array_data))) write(array_data) @@ -367,17 +367,17 @@ if isinstance(v, (string_t, bytes)): if isinstance(v, string): v = v.encode('utf-8') - write(pack(b'>cI', b'S', len(v))) + write(pack('>cI', b'S', len(v))) write(v) elif isinstance(v, bool): - write(pack(b'>cB', b't', int(v))) + write(pack('>cB', b't', int(v))) elif isinstance(v, float): - write(pack(b'>cd', b'd', v)) + write(pack('>cd', b'd', v)) elif isinstance(v, int_types): if v > 2147483647 or v < -2147483647: - write(pack(b'>cq', b'L', v)) + write(pack('>cq', b'L', v)) else: - write(pack(b'>ci', b'I', v)) + write(pack('>ci', b'I', v)) elif isinstance(v, Decimal): sign, digits, exponent = v.as_tuple() v = 0 @@ -385,9 +385,10 @@ v = (v * 10) + d if sign: v = -v - write(pack(b'>cBi', b'D', -exponent, v)) + write(pack('>cBi', b'D', -exponent, v)) elif isinstance(v, datetime): - write(pack(b'>cQ', b'T', long_t(calendar.timegm(v.utctimetuple())))) + write( + pack('>cQ', b'T', long_t(calendar.timegm(v.utctimetuple())))) elif isinstance(v, dict): write(b'F') _write_table(v, write, bits) @@ -405,16 +406,16 @@ """Decode basic properties.""" properties = {} - flags, = unpack_from(b'>H', buf, offset) + flags, = unpack_from('>H', buf, offset) offset += 2 if flags & 0x8000: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['content_type'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x4000: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['content_encoding'] = pstr_t(buf[offset:offset + slen]) offset += slen @@ -422,51 +423,51 @@ _f, offset = loads('F', buf, offset) properties['application_headers'], = _f if flags & 0x1000: - properties['delivery_mode'], = unpack_from(b'>B', buf, offset) + properties['delivery_mode'], = unpack_from('>B', buf, offset) offset += 1 if flags & 0x0800: - properties['priority'], = unpack_from(b'>B', buf, offset) + properties['priority'], = unpack_from('>B', buf, offset) offset += 1 if flags & 0x0400: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['correlation_id'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0200: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['reply_to'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0100: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['expiration'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0080: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['message_id'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0040: - properties['timestamp'], = unpack_from(b'>Q', buf, offset) + properties['timestamp'], = unpack_from('>Q', buf, offset) offset += 8 if flags & 0x0020: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['type'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0010: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['user_id'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0008: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['app_id'] = pstr_t(buf[offset:offset + slen]) offset += slen if flags & 0x0004: - slen, = unpack_from(b'>B', buf, offset) + slen, = unpack_from('>B', buf, offset) offset += 1 properties['cluster_id'] = pstr_t(buf[offset:offset + slen]) offset += slen @@ -552,13 +553,13 @@ result = BytesIO() write = result.write for flag_bits in flags: - write(pack(b'>H', flag_bits)) + write(pack('>H', flag_bits)) write(dumps(b''.join(sformat), svalues)) return result.getvalue() def inbound_header(self, buf, offset=0): - class_id, self.body_size = unpack_from(b'>HxxQ', buf, offset) + class_id, self.body_size = unpack_from('>HxxQ', buf, offset) offset += 12 self._load_properties(class_id, buf, offset) if not self.body_size: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp/transport.py new/amqp-2.1.4/amqp/transport.py --- old/amqp-2.1.3/amqp/transport.py 2016-12-08 02:40:07.000000000 +0100 +++ new/amqp-2.1.4/amqp/transport.py 2016-12-14 23:57:32.000000000 +0100 @@ -17,18 +17,18 @@ from __future__ import absolute_import, unicode_literals import errno -import math import re -import struct import socket import ssl from contextlib import contextmanager -from struct import unpack from .exceptions import UnexpectedFrame from .five import items -from .platform import SOL_TCP, TCP_USER_TIMEOUT, HAS_TCP_USER_TIMEOUT +from .platform import ( + SOL_TCP, TCP_USER_TIMEOUT, HAS_TCP_USER_TIMEOUT, + pack, unpack, +) from .utils import get_errno, set_cloexec try: @@ -61,9 +61,26 @@ TCP_OPTS = { getattr(socket, opt) for opt in KNOWN_TCP_OPTS if hasattr(socket, opt) } +DEFAULT_SOCKET_SETTINGS = { + socket.TCP_NODELAY: 1, +} + if HAS_TCP_USER_TIMEOUT: KNOWN_TCP_OPTS += ('TCP_USER_TIMEOUT',) TCP_OPTS.add(TCP_USER_TIMEOUT) + DEFAULT_SOCKET_SETTINGS[TCP_USER_TIMEOUT] = 1000 + + +try: + from socket import TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT # noqa +except ImportError: + pass +else: + DEFAULT_SOCKET_SETTINGS.update({ + TCP_KEEPIDLE: 60, + TCP_KEEPINTVL: 10, + TCP_KEEPCNT: 9, + }) def to_host_port(host, default=AMQP_PORT): @@ -162,7 +179,7 @@ if interval is not None: self.sock.setsockopt( socket.SOL_SOCKET, timeout, - struct.pack(b'll', interval, 0), + pack('ll', interval, 0), ) self._setup_transport() @@ -178,22 +195,11 @@ } def _set_socket_options(self, socket_settings): - user_timeout = 0 - if self.connect_timeout is not None: - user_timeout = int(math.ceil(self.connect_timeout * 1000.0)) - - if not socket_settings: - self.sock.setsockopt(SOL_TCP, socket.TCP_NODELAY, 1) - if HAS_TCP_USER_TIMEOUT: - self.sock.setsockopt(SOL_TCP, TCP_USER_TIMEOUT, user_timeout) - return - tcp_opts = self._get_tcp_socket_defaults(self.sock) - tcp_opts.setdefault(socket.TCP_NODELAY, 1) - if HAS_TCP_USER_TIMEOUT: - tcp_opts.setdefault(TCP_USER_TIMEOUT, user_timeout) - tcp_opts.update(socket_settings) - + final_socket_settings = dict(DEFAULT_SOCKET_SETTINGS) + if socket_settings: + final_socket_settings.update(socket_settings) + tcp_opts.update(final_socket_settings) for opt, val in items(tcp_opts): self.sock.setsockopt(SOL_TCP, opt, val) @@ -230,7 +236,7 @@ try: frame_header = read(7, True) read_frame_buffer += frame_header - frame_type, channel, size = unpack(b'>BHI', frame_header) + frame_type, channel, size = unpack('>BHI', frame_header) # >I is an unsigned int, but the argument to sock.recv is signed, # so we know the size can be at most 2 * SIGNED_INT_MAX if size > SIGNED_INT_MAX: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp.egg-info/PKG-INFO new/amqp-2.1.4/amqp.egg-info/PKG-INFO --- old/amqp-2.1.3/amqp.egg-info/PKG-INFO 2016-12-08 02:51:09.000000000 +0100 +++ new/amqp-2.1.4/amqp.egg-info/PKG-INFO 2016-12-15 00:52:08.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: amqp -Version: 2.1.3 +Version: 2.1.4 Summary: Low-level AMQP client for Python (fork of amqplib). Home-page: http://github.com/celery/py-amqp Author: Ask Solem @@ -12,7 +12,7 @@ |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| - :Version: 2.1.3 + :Version: 2.1.4 :Web: https://amqp.readthedocs.io/ :Download: http://pypi.python.org/pypi/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/amqp.egg-info/SOURCES.txt new/amqp-2.1.4/amqp.egg-info/SOURCES.txt --- old/amqp-2.1.3/amqp.egg-info/SOURCES.txt 2016-12-08 02:51:09.000000000 +0100 +++ new/amqp-2.1.4/amqp.egg-info/SOURCES.txt 2016-12-15 00:52:08.000000000 +0100 @@ -63,6 +63,7 @@ t/unit/test_connection.py t/unit/test_exceptions.py t/unit/test_method_framing.py +t/unit/test_platform.py t/unit/test_serialization.py t/unit/test_transport.py t/unit/test_utils.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/docs/includes/introduction.txt new/amqp-2.1.4/docs/includes/introduction.txt --- old/amqp-2.1.3/docs/includes/introduction.txt 2016-12-08 02:46:53.000000000 +0100 +++ new/amqp-2.1.4/docs/includes/introduction.txt 2016-12-15 00:51:26.000000000 +0100 @@ -1,4 +1,4 @@ -:Version: 2.1.3 +:Version: 2.1.4 :Web: https://amqp.readthedocs.io/ :Download: http://pypi.python.org/pypi/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/t/unit/test_method_framing.py new/amqp-2.1.4/t/unit/test_method_framing.py --- old/amqp-2.1.3/t/unit/test_method_framing.py 2016-12-08 02:40:07.000000000 +0100 +++ new/amqp-2.1.4/t/unit/test_method_framing.py 2016-12-14 23:59:42.000000000 +0100 @@ -2,14 +2,13 @@ import pytest -from struct import pack - from case import Mock from amqp import spec from amqp.basic_message import Message from amqp.exceptions import UnexpectedFrame from amqp.method_framing import frame_handler, frame_writer +from amqp.platform import pack class test_frame_handler: @@ -22,21 +21,21 @@ self.g = frame_handler(self.conn, self.callback) def test_header(self): - buf = pack(b'>HH', 60, 51) + buf = pack('>HH', 60, 51) self.g((1, 1, buf)) self.callback.assert_called_with(1, (60, 51), buf, None) assert self.conn.bytes_recv def test_header_message_empty_body(self): - self.g((1, 1, pack(b'>HH', *spec.Basic.Deliver))) + self.g((1, 1, pack('>HH', *spec.Basic.Deliver))) self.callback.assert_not_called() with pytest.raises(UnexpectedFrame): - self.g((1, 1, pack(b'>HH', *spec.Basic.Deliver))) + self.g((1, 1, pack('>HH', *spec.Basic.Deliver))) m = Message() m.properties = {} - buf = pack(b'>HxxQ', m.CLASS_ID, 0) + buf = pack('>HxxQ', m.CLASS_ID, 0) buf += m._serialize_properties() self.g((2, 1, buf)) @@ -47,12 +46,12 @@ ) def test_header_message_content(self): - self.g((1, 1, pack(b'>HH', *spec.Basic.Deliver))) + self.g((1, 1, pack('>HH', *spec.Basic.Deliver))) self.callback.assert_not_called() m = Message() m.properties = {} - buf = pack(b'>HxxQ', m.CLASS_ID, 16) + buf = pack('>HxxQ', m.CLASS_ID, 16) buf += m._serialize_properties() self.g((2, 1, buf)) self.callback.assert_not_called() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/t/unit/test_platform.py new/amqp-2.1.4/t/unit/test_platform.py --- old/amqp-2.1.3/t/unit/test_platform.py 1970-01-01 01:00:00.000000000 +0100 +++ new/amqp-2.1.4/t/unit/test_platform.py 2016-12-14 23:39:46.000000000 +0100 @@ -0,0 +1,14 @@ +from __future__ import absolute_import, unicode_literals +import pytest +from amqp.platform import _linux_version_to_tuple + + [email protected]('s,expected', [ + ('3.13.0-46-generic', (3, 13, 0)), + ('3.19.43-1-amd64', (3, 19, 43)), + ('4.4.34+', (4, 4, 34)), + ('4.4.what', (4, 4, 0)), + ('4.what.what', (4, 0, 0)), +]) +def test_linux_version_to_tuple(s, expected): + assert _linux_version_to_tuple(s) == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/t/unit/test_serialization.py new/amqp-2.1.4/t/unit/test_serialization.py --- old/amqp-2.1.3/t/unit/test_serialization.py 2016-12-08 02:40:07.000000000 +0100 +++ new/amqp-2.1.4/t/unit/test_serialization.py 2016-12-15 00:00:19.000000000 +0100 @@ -5,10 +5,10 @@ from datetime import datetime from decimal import Decimal from math import ceil -from struct import pack from amqp.basic_message import Message from amqp.exceptions import FrameSyntaxError +from amqp.platform import pack from amqp.serialization import GenericContent, _read_item, dumps, loads @@ -25,14 +25,14 @@ @pytest.mark.parametrize('descr,frame,expected,cast', [ ('S', b's8thequick', 'thequick', None), - ('b', b'b' + pack(b'>B', True), True, None), - ('B', b'B' + pack(b'>b', 123), 123, None), - ('U', b'U' + pack(b'>h', -321), -321, None), - ('u', b'u' + pack(b'>H', 321), 321, None), - ('i', b'i' + pack(b'>I', 1234), 1234, None), - ('L', b'L' + pack(b'>q', -32451), -32451, None), - ('l', b'l' + pack(b'>Q', 32451), 32451, None), - ('f', b'f' + pack(b'>f', 33.3), 34.0, ceil), + ('b', b'b' + pack('>B', True), True, None), + ('B', b'B' + pack('>b', 123), 123, None), + ('U', b'U' + pack('>h', -321), -321, None), + ('u', b'u' + pack('>H', 321), 321, None), + ('i', b'i' + pack('>I', 1234), 1234, None), + ('L', b'L' + pack('>q', -32451), -32451, None), + ('l', b'l' + pack('>Q', 32451), 32451, None), + ('f', b'f' + pack('>f', 33.3), 34.0, ceil), ]) def test_read_item(self, descr, frame, expected, cast): actual = _read_item(frame)[0] @@ -162,7 +162,7 @@ 'content_encoding': 'utf-8', } body = 'the quick brown fox' - buf = b'\0' * 30 + pack(b'>HxxQ', m.CLASS_ID, len(body)) + buf = b'\0' * 30 + pack('>HxxQ', m.CLASS_ID, len(body)) buf += m._serialize_properties() assert m.inbound_header(buf, offset=30) == 42 assert m.body_size == len(body) @@ -172,7 +172,7 @@ def test_inbound_header__empty_body(self): m = Message() m.properties = {} - buf = pack(b'>HxxQ', m.CLASS_ID, 0) + buf = pack('>HxxQ', m.CLASS_ID, 0) buf += m._serialize_properties() assert m.inbound_header(buf, offset=0) == 12 assert m.ready diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-2.1.3/t/unit/test_transport.py new/amqp-2.1.4/t/unit/test_transport.py --- old/amqp-2.1.3/t/unit/test_transport.py 2016-12-08 02:40:07.000000000 +0100 +++ new/amqp-2.1.4/t/unit/test_transport.py 2016-12-15 00:00:41.000000000 +0100 @@ -4,12 +4,11 @@ import socket import pytest -from struct import pack - from case import Mock, patch from amqp import transport from amqp.exceptions import UnexpectedFrame +from amqp.platform import pack class MockSocket(object): @@ -264,11 +263,11 @@ self.t._read.return_value = b'thequickbrownfox' self.t._read.side_effect = on_read2 return ret - self.t._read.return_value = pack(b'>BHI', 1, 1, 16) + self.t._read.return_value = pack('>BHI', 1, 1, 16) self.t._read.side_effect = on_read1 self.t.read_frame() - self.t._read.return_value = pack(b'>BHI', 1, 1, 16) + self.t._read.return_value = pack('>BHI', 1, 1, 16) self.t._read.side_effect = on_read1 checksum[0] = b'\x13' with pytest.raises(UnexpectedFrame):
