Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-amqp for openSUSE:Factory checked in at 2026-11-20 14:47:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-amqp (Old) and /work/SRC/openSUSE:Factory/.python-amqp.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-amqp" Fri Nov 20 14:47:05 2026 rev:47 rq:1398852 version:5.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-amqp/python-amqp.changes 2026-09-28 10:46:27.582970360 +0200 +++ /work/SRC/openSUSE:Factory/.python-amqp.new.1251/python-amqp.changes 2026-11-20 14:49:59.988692672 +0100 @@ -1,0 +2,13 @@ +Fri Nov 20 01:08:32 UTC 2026 - Steve Kowalik <[email protected]> + +- Update to 5.4.2: + * Fix publisher confirm state after channel revive + * Fix non-UTF-8 field-table keys + * Always return the consumer tag from basic_consume + * Forget no_ack consumers cancelled by the broker + * Send the content header for empty bodies on the slow write path + * Flush pending bits around timestamp and byte array fields + * Fix signedness of byte fields in AMQP tables + * Decode AMQP field-table types 'b' and 'B' with the right signedness + +------------------------------------------------------------------- Old: ---- amqp-5.4.0.tar.gz New: ---- amqp-5.4.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-amqp.spec ++++++ --- /var/tmp/diff_new_pack.38Xo6I/_old 2026-11-20 14:50:00.853729226 +0100 +++ /var/tmp/diff_new_pack.38Xo6I/_new 2026-11-20 14:50:00.856729352 +0100 @@ -18,14 +18,13 @@ %{?sle15_python_module_pythons} Name: python-amqp -Version: 5.4.0 +Version: 5.4.2 Release: 0 Summary: Low-level AMQP client for Python (fork of amqplib) License: LGPL-2.1-or-later URL: https://github.com/celery/py-amqp Source: https://files.pythonhosted.org/packages/source/a/amqp/amqp-%{version}.tar.gz -BuildRequires: %{python_module base >= 3.8} -BuildRequires: %{python_module case >= 1.3.1} +BuildRequires: %{python_module base >= 3.10} BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest >= 3.0} BuildRequires: %{python_module setuptools} ++++++ amqp-5.4.0.tar.gz -> amqp-5.4.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/Changelog new/amqp-5.4.2/Changelog --- old/amqp-5.4.0/Changelog 2026-09-19 10:34:14.981160900 +0200 +++ new/amqp-5.4.2/Changelog 2026-11-02 11:28:37.528033500 +0100 @@ -6,6 +6,32 @@ http://code.google.com/p/py-amqplib/source/browse/CHANGES +.. _version-5.4.2: + +5.4.2 +===== +:release-date: 2026-11-02 +:release-by: Asif Saif Uddin (@auvipy) + +- Fix publisher confirm state after channel revive (#477). +- Fix non-UTF-8 field-table keys. +- Always return the consumer tag from basic_consume (#481). +- Forget no_ack consumers cancelled by the broker - #483. +- Send the content header for empty bodies on the slow write path. +- Flush pending bits around timestamp and byte array fields (#484). + + + +.. _version-5.4.1: + +5.4.1 +===== +:release-date: 2026-10-05 +:release-by: Asif Saif Uddin (@auvipy) + +- Fix signedness of byte fields in AMQP tables - #472 + + .. _version-5.4.0: 5.4.0 @@ -202,7 +228,7 @@ Contributed by **Omer Katz** -- Added debug representation to Connection and *Transport classes +- Added debug representation to Connection and *Transport* classes Contributed by **Matus Valo** @@ -277,7 +303,7 @@ - **Omer Katz** -.. _version-2.6.0: +.. _version-2.6.1: 2.6.1 ===== @@ -285,9 +311,9 @@ :release-by: Asif Saif Uddin - Fix buffer overflow in frame_writer after frame_max is increased. `frame_writer` -allocates a `bytearray` on initialization with a length based on the `connection.frame_max` -value. If `connection.frame_max` is changed to a larger value, this causes an -error like `pack_into requires a buffer of at least 408736 bytes`. + allocates a `bytearray` on initialization with a length based on the `connection.frame_max` + value. If `connection.frame_max` is changed to a larger value, this causes an + error like `pack_into requires a buffer of at least 408736 bytes`. .. _version-2.6.0: @@ -340,7 +366,8 @@ - Drop Python 3.4 - Add new platform -- Numerious bug fixes +- Numerous bug fixes + .. _version-2.4.2: 2.4.2 @@ -701,14 +728,14 @@ ===== :release-date: 2016-12-07 02:00 P.M PST -- Linux: Now sets the :data:`~socket.TCP_USER_TIMEOUT` flag if available +- Linux: Now sets the ``socket.TCP_USER_TIMEOUT`` flag if available for better failed connection detection. Contributed by **Jelte Fennema**. The timeout is set to the ``connect_timeout`` value by default, but can also be specified by using the ``socket_settings`` argument - to :class:`~amqp.Connection`: + to :class:`~amqp.connection.Connection`: .. code-block:: python @@ -763,7 +790,7 @@ - **Requirements** - - Now depends on :ref:`Vine 1.1.3 <vine:version-1.1.3>`. + - Now depends on :pypi:`vine` 1.1.3. - Frame writer: Account for overhead when calculating frame size. @@ -787,7 +814,7 @@ - **Requirements** - - Now depends on :ref:`Vine 1.1.2 <vine:version-1.1.2>`. + - Now depends on :pypi:`vine` 1.1.2. - Now licensed under the BSD license! @@ -970,7 +997,7 @@ Fix contributed by Eric Wang. -- ``channel.basic_publish`` now raises :exc:`amqp.exceptions.NotConfirmed` on +- ``channel.basic_publish`` now raises ``NotConfirmed`` on ``basic.nack``. - AMQP timestamps received are now converted from GMT instead of local time @@ -1155,7 +1182,7 @@ and now it's possible by configuration. - ``queue_declare`` now returns named tuple of type - :class:`~amqp.protocol.basic_declare_ok_t`. + :class:`~amqp.protocol.queue_declare_ok_t`. Supporting fields: ``queue``, ``message_count``, and ``consumer_count``. @@ -1179,7 +1206,7 @@ :release-date: 2013-08-16 05:30 P.M UTC :release-by: Ask Solem -- Adds promise type: :meth:`amqp.utils.promise` +- Adds promise type: `promise` - Merges fixes from 1.0.x @@ -1192,31 +1219,31 @@ - New exception hierarchy: - - :class:`~amqp.AMQPError` - - :class:`~amqp.ConnectionError` - - :class:`~amqp.RecoverableConnectionError` - - :class:`~amqp.ConsumerCancelled` - - :class:`~amqp.ConnectionForced` - - :class:`~amqp.ResourceError` - - :class:`~IrrecoverableConnectionError` - - :class:`~amqp.ChannelNotOpen` - - :class:`~amqp.FrameError` - - :class:`~amqp.FrameSyntaxError` - - :class:`~amqp.InvalidCommand` - - :class:`~amqp.InvalidPath` - - :class:`~amqp.NotAllowed` - - :class:`~amqp.UnexpectedFrame` - - :class:`~amqp.AMQPNotImplementedError` - - :class:`~amqp.InternalError` - - :class:`~amqp.ChannelError` - - :class:`~RecoverableChannelError` - - :class:`~amqp.ContentTooLarge` - - :class:`~amqp.NoConsumers` - - :class:`~amqp.ResourceLocked` - - :class:`~IrrecoverableChannelError` - - :class:`~amqp.AccessRefused` - - :class:`~amqp.NotFound` - - :class:`~amqp.PreconditionFailed` + - :class:`~amqp.exceptions.AMQPError` + - :class:`~amqp.exceptions.ConnectionError` + - :class:`~amqp.exceptions.RecoverableConnectionError` + - :class:`~amqp.exceptions.ConsumerCancelled` + - :class:`~amqp.exceptions.ConnectionForced` + - :class:`~amqp.exceptions.ResourceError` + - :class:`~amqp.exceptions.IrrecoverableConnectionError` + - :class:`~amqp.exceptions.ChannelNotOpen` + - :class:`~amqp.exceptions.FrameError` + - :class:`~amqp.exceptions.FrameSyntaxError` + - :class:`~amqp.exceptions.InvalidCommand` + - :class:`~amqp.exceptions.InvalidPath` + - :class:`~amqp.exceptions.NotAllowed` + - :class:`~amqp.exceptions.UnexpectedFrame` + - :class:`~amqp.exceptions.AMQPNotImplementedError` + - :class:`~amqp.exceptions.InternalError` + - :class:`~amqp.exceptions.ChannelError` + - :class:`~amqp.exceptions.RecoverableChannelError` + - :class:`~amqp.exceptions.ContentTooLarge` + - :class:`~amqp.exceptions.NoConsumers` + - :class:`~amqp.exceptions.ResourceLocked` + - :class:`~amqp.exceptions.IrrecoverableChannelError` + - :class:`~amqp.exceptions.AccessRefused` + - :class:`~amqp.exceptions.NotFound` + - :class:`~amqp.exceptions.PreconditionFailed` .. _version-1.1.0: @@ -1356,7 +1383,7 @@ - Now uses :class:`array.array` to keep track of unused channel ids. -- The :data:`~amqp.exceptions.METHOD_NAME_MAP` has been updated for +- The ``amqp.exceptions.METHOD_NAME_MAP`` has been updated for amqp/0.9.1 and Rabbit extensions. - Removed a bunch of accidentally included images. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/PKG-INFO new/amqp-5.4.2/PKG-INFO --- old/amqp-5.4.0/PKG-INFO 2026-09-19 10:37:55.686862000 +0200 +++ new/amqp-5.4.2/PKG-INFO 2026-11-02 11:32:53.253856000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: amqp -Version: 5.4.0 +Version: 5.4.2 Summary: Low-level AMQP client for Python (fork of amqplib). Home-page: http://github.com/celery/py-amqp Author: Barry Pederson @@ -48,7 +48,7 @@ |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| -:Version: 5.4.0 +:Version: 5.4.2 :Web: https://amqp.readthedocs.io/ :Download: https://pypi.org/project/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/README.rst new/amqp-5.4.2/README.rst --- old/amqp-5.4.0/README.rst 2026-09-19 10:34:14.981480100 +0200 +++ new/amqp-5.4.2/README.rst 2026-11-02 11:28:37.528309000 +0100 @@ -4,7 +4,7 @@ |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| -:Version: 5.4.0 +:Version: 5.4.2 :Web: https://amqp.readthedocs.io/ :Download: https://pypi.org/project/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp/__init__.py new/amqp-5.4.2/amqp/__init__.py --- old/amqp-5.4.0/amqp/__init__.py 2026-09-19 10:34:14.981763600 +0200 +++ new/amqp-5.4.2/amqp/__init__.py 2026-11-02 11:28:37.528516800 +0100 @@ -4,7 +4,7 @@ import re from collections import namedtuple -__version__ = '5.4.0' +__version__ = '5.4.2' __author__ = 'Barry Pederson' __maintainer__ = 'Asif Saif Uddin' __contact__ = '[email protected]' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp/channel.py new/amqp-5.4.2/amqp/channel.py --- old/amqp-5.4.0/amqp/channel.py 2026-09-19 09:36:43.295942500 +0200 +++ new/amqp-5.4.2/amqp/channel.py 2026-11-02 10:36:54.955199500 +0100 @@ -174,6 +174,7 @@ def _do_revive(self): self.is_open = False + self._confirm_selected = False self.open() def close(self, reply_code=0, reply_text='', method_sig=(0, 0), @@ -1470,6 +1471,7 @@ self._remove_tag(consumer_tag) def _remove_tag(self, consumer_tag): + self.no_ack_consumers.discard(consumer_tag) self.callbacks.pop(consumer_tag, None) return self.cancel_callbacks.pop(consumer_tag, None) @@ -1570,7 +1572,17 @@ as the single argument. If no callable is specified, messages are quietly discarded, no_ack should probably be set to True in that case. + + Returns the consumer tag. When nowait is False this is the tag + confirmed by the server (generated by the server if none was + given). When nowait is True a consumer tag must be given and + it is returned unchanged. """ + if nowait and not consumer_tag: + raise ValueError( + 'Consumer tag must be specified when nowait is True' + ) + p = self.send_method( spec.Basic.Consume, argsig, ( @@ -1589,10 +1601,6 @@ # * consumer_tag is provided by client, the same one # is returned by broker consumer_tag = p[0] - elif nowait and not consumer_tag: - raise ValueError( - 'Consumer tag must be specified when nowait is True' - ) self.callbacks[consumer_tag] = callback @@ -1601,10 +1609,7 @@ if no_ack: self.no_ack_consumers.add(consumer_tag) - if not nowait: - return consumer_tag - else: - return p + return consumer_tag def _on_basic_deliver(self, consumer_tag, delivery_tag, redelivered, exchange, routing_key, msg): @@ -1884,15 +1889,13 @@ a_global: boolean Defines a scope of QoS. Semantics of this parameter differs - between AMQP 0-9-1 standard and RabbitMQ broker: - - MEANING IN AMQP 0-9-1: - False: shared across all consumers on the channel - True: shared across all consumers on the connection - MEANING IN RABBITMQ: - False: applied separately to each new consumer - on the channel - True: shared across all consumers on the channel + between the AMQP 0-9-1 standard and RabbitMQ broker. + For AMQP 0-9-1, ``False`` is shared across all consumers + on the channel, while ``True`` is shared across all + consumers on the connection. + For RabbitMQ, ``False`` is applied separately to each new + consumer on the channel, while ``True`` is shared across + all consumers on the channel. """ return self.send_method( spec.Basic.Qos, argsig, (prefetch_size, prefetch_count, a_global), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp/connection.py new/amqp-5.4.2/amqp/connection.py --- old/amqp-5.4.0/amqp/connection.py 2026-09-19 09:36:43.296094400 +0200 +++ new/amqp-5.4.2/amqp/connection.py 2026-11-02 10:36:54.955492500 +0100 @@ -79,6 +79,7 @@ use-connection = *channel close-connection = C:CLOSE S:CLOSE-OK / S:CLOSE C:CLOSE-OK + Create a connection to the specified host, which should be a 'host[:port]', such as 'localhost', or '1.2.3.4:5672' (defaults to 'localhost', if a port is not specified then @@ -114,10 +115,12 @@ #: and if a key in this map is present the client will tell the #: server to either enable or disable the capability depending #: on the value set in this map. - #: For example with: + #: For example with:: + #: #: negotiate_capabilities = { #: 'consumer_cancel_notify': True, #: } + #: #: The client will enable this capability if the server reports #: support for it, but if the value is False the client will #: disable the capability. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp/method_framing.py new/amqp-5.4.2/amqp/method_framing.py --- old/amqp-5.4.0/amqp/method_framing.py 2026-09-19 09:36:43.296426500 +0200 +++ new/amqp-5.4.2/amqp/method_framing.py 2026-11-02 10:36:54.955911400 +0100 @@ -147,7 +147,7 @@ framelen = len(frame) write(pack('>BHI%dsB' % framelen, type_, channel, framelen, frame, 0xce)) - if body: + if body is not None: frame = b''.join([ pack('>HHQ', method_sig[0], 0, len(body)), properties, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp/serialization.py new/amqp-5.4.2/amqp/serialization.py --- old/amqp-5.4.0/amqp/serialization.py 2026-09-19 09:36:43.296854700 +0200 +++ new/amqp-5.4.2/amqp/serialization.py 2026-11-02 10:36:54.956377000 +0100 @@ -58,11 +58,11 @@ offset += blen # 'b': short-short int elif ftype == 'b': - val, = unpack_from('>B', buf, offset) + val, = unpack_from('>b', buf, offset) offset += 1 # 'B': short-short unsigned int elif ftype == 'B': - val, = unpack_from('>b', buf, offset) + val, = unpack_from('>B', buf, offset) offset += 1 # 'U': short int elif ftype == 'U': @@ -115,7 +115,10 @@ while offset < limit: keylen, = unpack_from('>B', buf, offset) offset += 1 - key = pstr_t(buf[offset:offset + keylen]) + try: + key = pstr_t(buf[offset:offset + keylen]) + except UnicodeDecodeError: + key = buf[offset:offset + keylen] offset += keylen val[key], offset = _read_item(buf, offset) # 'A': array @@ -210,6 +213,7 @@ val = buf[offset:offset + slen].decode('utf-8', 'surrogatepass') offset += slen elif p == 'x': + bitcount = bits = 0 blen, = unpack_from('>I', buf, offset) offset += 4 val = buf[offset:offset + blen] @@ -223,7 +227,10 @@ while offset < limit: keylen, = unpack_from('>B', buf, offset) offset += 1 - key = pstr_t(buf[offset:offset + keylen]) + try: + key = pstr_t(buf[offset:offset + keylen]) + except UnicodeDecodeError: + key = buf[offset:offset + keylen] offset += keylen val[key], offset = _read_item(buf, offset) elif p == 'A': @@ -321,6 +328,7 @@ bitcount = _flushbits(bits, write) _write_array(val or [], write, bits) elif p == 'T': + bitcount = _flushbits(bits, write) write(pack('>Q', int(calendar.timegm(val.utctimetuple())))) _flushbits(bits, write) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp/transport.py new/amqp-5.4.2/amqp/transport.py --- old/amqp-5.4.0/amqp/transport.py 2026-09-19 09:36:43.297068600 +0200 +++ new/amqp-5.4.2/amqp/transport.py 2026-11-02 10:36:54.956817000 +0100 @@ -433,7 +433,7 @@ ctx_options - Parameters of :attr:`ssl.create_default_context`. + Parameters of :func:`ssl.create_default_context`. """ ctx = ssl.create_default_context(**ctx_options) ctx.check_hostname = check_hostname @@ -471,15 +471,15 @@ cert_reqs: ssl.VerifyMode - When set to other than :attr:`ssl.CERT_NONE`, peers certificate - is checked. Possible values are :attr:`ssl.CERT_NONE`, - :attr:`ssl.CERT_OPTIONAL` and :attr:`ssl.CERT_REQUIRED`. + When set to other than :data:`ssl.CERT_NONE`, peers certificate + is checked. Possible values are :data:`ssl.CERT_NONE`, + :data:`ssl.CERT_OPTIONAL` and :data:`ssl.CERT_REQUIRED`. ca_certs: str Path to “certification authority” (CA) certificates used to validate other peers’ certificates when ``cert_reqs`` - is other than :attr:`ssl.CERT_NONE`. + is other than :data:`ssl.CERT_NONE`. do_handshake_on_connect: bool diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/amqp.egg-info/PKG-INFO new/amqp-5.4.2/amqp.egg-info/PKG-INFO --- old/amqp-5.4.0/amqp.egg-info/PKG-INFO 2026-09-19 10:37:55.651678600 +0200 +++ new/amqp-5.4.2/amqp.egg-info/PKG-INFO 2026-11-02 11:32:53.218609300 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: amqp -Version: 5.4.0 +Version: 5.4.2 Summary: Low-level AMQP client for Python (fork of amqplib). Home-page: http://github.com/celery/py-amqp Author: Barry Pederson @@ -48,7 +48,7 @@ |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| -:Version: 5.4.0 +:Version: 5.4.2 :Web: https://amqp.readthedocs.io/ :Download: https://pypi.org/project/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/docs/conf.py new/amqp-5.4.2/docs/conf.py --- old/amqp-5.4.0/docs/conf.py 2026-09-19 09:36:43.297850100 +0200 +++ new/amqp-5.4.2/docs/conf.py 2026-11-02 10:36:54.957168300 +0100 @@ -1,3 +1,5 @@ +import sys + from sphinx_celery import conf globals().update(conf.build_config( @@ -21,3 +23,12 @@ apicheck_package='amqp', apicheck_ignore_modules=['amqp'], )) + +# apicheck is only required for the apicheck builder. +if not any(arg == 'apicheck' for arg in sys.argv): + extensions.remove('sphinx_celery.apicheck') + +# GSSAPI may be backed by a local fallback class when gssapi is unavailable. +nitpick_ignore = [ + ('py:class', 'amqp.sasl._get_gssapi_mechanism.<locals>.FakeGSSAPI'), +] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/docs/includes/introduction.txt new/amqp-5.4.2/docs/includes/introduction.txt --- old/amqp-5.4.0/docs/includes/introduction.txt 2026-09-19 10:34:14.982070700 +0200 +++ new/amqp-5.4.2/docs/includes/introduction.txt 2026-11-02 11:28:37.528727800 +0100 @@ -1,4 +1,4 @@ -:Version: 5.4.0 +:Version: 5.4.2 :Web: https://amqp.readthedocs.io/ :Download: https://pypi.org/project/amqp/ :Source: http://github.com/celery/py-amqp/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/t/integration/test_integration.py new/amqp-5.4.2/t/integration/test_integration.py --- old/amqp-5.4.0/t/integration/test_integration.py 2026-09-19 09:36:43.301264000 +0200 +++ new/amqp-5.4.2/t/integration/test_integration.py 2026-11-02 10:36:54.957536500 +0100 @@ -701,6 +701,38 @@ assert ch.callbacks['my_tag'] == callback_mock assert ret == 'my_tag' + def test_consume_nowait_with_consumer_tag(self): + # Test verifying starting consuming with nowait and specified + # consumer_tag. Broker does not send ConsumeOk in this case. + callback_mock = Mock() + frame_writer_cls_mock = Mock() + conn = Connection(frame_writer=frame_writer_cls_mock) + with patch.object(conn, 'Transport') as transport_mock: + handshake(conn, transport_mock) + ch = create_channel(1, conn, transport_mock) + + transport_mock().read_frame.reset_mock() + frame_writer_mock = frame_writer_cls_mock() + frame_writer_mock.reset_mock() + ret = ch.basic_consume( + 'my_queue', callback=callback_mock, consumer_tag='my_tag', + nowait=True + ) + frame_writer_mock.assert_called_once_with( + 1, 1, spec.Basic.Consume, + dumps( + 'BssbbbbF', + ( + 0, 'my_queue', 'my_tag', + False, False, False, True, None + ) + ), + None + ) + transport_mock().read_frame.assert_not_called() + assert ch.callbacks['my_tag'] == callback_mock + assert ret == 'my_tag' + def test_queue_declare(self): # Test verifying declaring queue frame_writer_cls_mock = Mock() @@ -902,6 +934,45 @@ 'application_headers': {}, 'delivery_mode': 1 } + def test_consumer_cancelled_by_broker(self): + # Test verifying that a no_ack consumer cancelled by the broker + # (e.g. because its queue was deleted) is fully forgotten + callback_mock = Mock() + on_cancel_mock = Mock() + frame_writer_cls_mock = Mock() + conn = Connection(frame_writer=frame_writer_cls_mock) + consumer_tag = 'amq.ctag-PCmzXGkhCw_v0Zq7jXyvkg' + with patch.object(conn, 'Transport') as transport_mock: + handshake(conn, transport_mock) + ch = create_channel(1, conn, transport_mock) + + transport_mock().read_frame.side_effect = [ + # Inject Consume-ok response + build_frame_type_1( + spec.Basic.ConsumeOk, + channel=1, + args=(consumer_tag,), + arg_format='s' + ), + # Inject Basic.Cancel sent by broker + build_frame_type_1( + spec.Basic.Cancel, + channel=1, + args=(consumer_tag,), + arg_format='s' + ), + ] + ch.basic_consume( + 'my_queue', no_ack=True, + callback=callback_mock, on_cancel=on_cancel_mock, + ) + assert consumer_tag in ch.no_ack_consumers + conn.drain_events() + on_cancel_mock.assert_called_once_with(consumer_tag) + assert consumer_tag not in ch.callbacks + assert consumer_tag not in ch.cancel_callbacks + assert consumer_tag not in ch.no_ack_consumers + def test_queue_get(self): # Test verifying getting message from queue frame_writer_cls_mock = Mock() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/t/integration/test_rmq.py new/amqp-5.4.2/t/integration/test_rmq.py --- old/amqp-5.4.0/t/integration/test_rmq.py 2026-09-19 09:36:43.301426000 +0200 +++ new/amqp-5.4.2/t/integration/test_rmq.py 2026-10-05 15:39:55.875567200 +0200 @@ -253,3 +253,32 @@ assert msg.properties == {'application_headers': {'key': 128}} self.channel.basic_ack(msg.delivery_tag) + + @pytest.mark.flaky(reruns=5, reruns_delay=2) + def test_publish_get__short_short_int_header(self): + class ShortShortIntHeaderMessage(amqp.Message): + # application_headers={'signed': -1, 'unsigned': 200} typed 'b' + # and 'B'; py-amqp's own writer never emits either. + def _serialize_properties(self): + flags = pack('>H', 1 << 13) + signed = b'\x06signed' + b'b' + pack('>b', -1) + unsigned = b'\x08unsigned' + b'B' + pack('>B', 200) + table = signed + unsigned + return flags + pack('>I', len(table)) + table + + self.channel.queue_declare( + queue='py-amqp-unittest', durable=False, exclusive=True + ) + self.channel.basic_publish( + ShortShortIntHeaderMessage(b'Unittest'), + routing_key='py-amqp-unittest' + ) + msg = self.channel.basic_get( + queue='py-amqp-unittest', + ) + assert msg.body == b'Unittest' + assert msg.properties == { + 'application_headers': {'signed': -1, 'unsigned': 200} + } + + self.channel.basic_ack(msg.delivery_tag) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/t/unit/test_channel.py new/amqp-5.4.2/t/unit/test_channel.py --- old/amqp-5.4.0/t/unit/test_channel.py 2026-09-19 09:36:43.302006700 +0200 +++ new/amqp-5.4.2/t/unit/test_channel.py 2026-11-02 10:36:54.957868000 +0100 @@ -67,9 +67,13 @@ def test_do_revive(self): self.c.open = Mock(name='open') self.c.is_open = True + self.c._confirm_selected = True + self.c._do_revive() + assert not self.c.is_open - self.c.open.assert_called_with() + assert not self.c._confirm_selected + self.c.open.assert_called_once_with() def test_close__not_open(self): self.c.is_open = False @@ -275,6 +279,13 @@ assert 123 not in self.c.callbacks assert 123 not in self.c.cancel_callbacks + def test_on_basic_cancel__no_ack(self): + self.c.callbacks[123] = Mock() + self.c.cancel_callbacks[123] = Mock() + self.c.no_ack_consumers.add(123) + self.c._on_basic_cancel(123) + assert 123 not in self.c.no_ack_consumers + def test_basic_consume(self): callback = Mock() on_cancel = Mock() @@ -331,7 +342,7 @@ returns_tuple=True ) assert self.c.callbacks[123] is callback - assert ret == ret_promise + assert ret == 123 def test_basic_consume_no_wait_no_consumer_tag(self): callback = Mock() @@ -340,7 +351,8 @@ 'q', arguments={'x': 1}, callback=callback, nowait=True ) - assert 123 not in self.c.callbacks + self.c.send_method.assert_not_called() + assert not self.c.callbacks def test_on_basic_deliver(self): msg = Message() @@ -426,6 +438,28 @@ ) self.c.basic_publish_confirm(1, 2, arg=1) + def test_confirm_publish_reselects_after_channel_revival(self): + self.c.confirm_select = Mock(name='confirm_select') + self.c._basic_publish = Mock(name='_basic_publish') + self.c.wait = Mock(name='wait') + self.c.open = Mock(name='open') + + def publish(): + return self.c.basic_publish_confirm( + 1, 2, exchange='test', routing_key='key', + ) + + publish() + assert self.c.confirm_select.call_count == 1 + + with pytest.raises(NotFound): + self.c._on_close(404, 'channel closed', 50, 61) + + self.c.open.assert_called_once_with() + + publish() + assert self.c.confirm_select.call_count == 2 + def test_basic_publish_confirm_nack(self): # test checking whether library is handling correctly Nack confirms # sent from RabbitMQ. Library must raise MessageNacked when server diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/t/unit/test_method_framing.py new/amqp-5.4.2/t/unit/test_method_framing.py --- old/amqp-5.4.0/t/unit/test_method_framing.py 2026-09-19 09:36:43.302344600 +0200 +++ new/amqp-5.4.2/t/unit/test_method_framing.py 2026-11-02 10:36:54.958226000 +0100 @@ -109,6 +109,20 @@ self.write.assert_called() assert 'content_encoding' not in msg.properties + def test_write_slow_zero_len_body(self): + # Large headers push an empty message onto the slow path, which + # must still send the content header frame and no body frame. + msg = Message(body=b'', application_headers={'h': 'v' * 450}) + frame = 1, 1, spec.Basic.Publish, b'x' * 10, msg + self.g(*frame) + frame_types = [ + call[0][0][0] for call in self.write.call_args_list + ] + assert frame_types == [1, 2] + header = self.write.call_args[0][0] + assert header[7:11] == pack('>HH', spec.Basic.CLASS_ID, 0) + assert header[11:19] == pack('>Q', 0) + def test_write_fast_unicode(self): msg = Message(body='\N{CHECK MARK}') frame = 2, 1, spec.Basic.Publish, b'x' * 10, msg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/amqp-5.4.0/t/unit/test_serialization.py new/amqp-5.4.2/t/unit/test_serialization.py --- old/amqp-5.4.0/t/unit/test_serialization.py 2026-09-19 09:36:43.302607000 +0200 +++ new/amqp-5.4.2/t/unit/test_serialization.py 2026-11-02 10:36:54.958698700 +0100 @@ -28,7 +28,11 @@ ('S', b'S\x00\x00\x00\x03\xc0\xc0\x00', b'\xc0\xc0\x00', None), ('x', b'x\x00\x00\x00\x09thequick\xffIGNORED', b'thequick\xff', None), ('b', b'b' + pack('>B', True), True, None), + ('b-min', b'b' + pack('>b', -128), -128, None), + ('b-neg', b'b' + pack('>b', -1), -1, None), ('B', b'B' + pack('>b', 123), 123, None), + ('B-high', b'B' + pack('>B', 128), 128, None), + ('B-max', b'B' + pack('>B', 255), 255, 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), @@ -94,6 +98,45 @@ frame = b'\x00\x00\x00\x07\x03keys\x00\x80' assert loads(b'F', frame, 0)[0] == [{'key': 128}] + def test_table__non_utf8_key(self): + fields = b'\x01\xffI' + pack('>i', 42) + frame = pack('>I', len(fields)) + fields + + actual, offset = loads(b'F', frame, 0) + + assert actual == [{b'\xff': 42}] + assert offset == len(frame) + + def test_nested_table__non_utf8_key(self): + fields = b'\x01\xffI' + pack('>i', 42) + frame = b'F' + pack('>I', len(fields)) + fields + + actual, offset = _read_item(frame, 0) + + assert actual == {b'\xff': 42} + assert offset == len(frame) + + @pytest.mark.parametrize('tag,fmt,value', [ + (b'b', '>b', -128), (b'b', '>b', -1), + (b'b', '>b', 0), (b'b', '>b', 127), + (b'B', '>B', 0), (b'B', '>B', 127), + (b'B', '>B', 128), (b'B', '>B', 255), + ]) + def test_table__byte_values(self, tag, fmt, value): + # RabbitMQ uses b for signed bytes and B for unsigned bytes. + item = tag + pack(fmt, value) + nested = b'\x01v' + item + fields = b''.join(( + b'\x06nestedF' + pack('>I', len(nested)) + nested, + b'\x05arrayA' + pack('>I', len(item)) + item, + b'\x05afterI' + pack('>i', 42), + )) + frame = pack('>I', len(fields)) + fields + actual, offset = loads('F', frame, 0) + assert actual == [{'nested': {'v': value}, 'array': [value], + 'after': 42}] + assert offset == len(frame) + def test_table__unknown_type(self): table = { 'foo': object(), @@ -138,6 +181,28 @@ actual, _ = loads(format, buf, 0) assert actual == expected + @pytest.mark.parametrize('field,value', [ + ('o', 32), + ('B', 3415), + ('l', 4513134), + ('L', 13241923419), + ('f', 1.5), + ('s', 'thequickbrownfox'), + ('S', 'jumpsoverthelazydog'), + ('x', b'thequick\xff'), + ('F', {'foo': 32}), + ('A', [1, 'bar']), + ('T', datetime(2015, 3, 13, 10, 23)), + ]) + def test_bits_around_field(self, field, value): + # Any non-bit field ends the current run of bits, so the bits on + # each side of it must be packed into their own octet. + format = 'bb' + field + 'bb' + values = [True, False, value, False, True] + buf = dumps(format, values) + assert buf == b'\x01' + dumps(field, [value]) + b'\x02' + assert loads(format, buf, 0) == (values, len(buf)) + class test_GenericContent:
