From ba6e612ec4fa84ef7a63feea4b1a6e6e7a8c204c Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 15 Jan 2026 14:09:22 +0000 Subject: [PATCH 1/2] mitogen: Fix docstring typo --- mitogen/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitogen/core.py b/mitogen/core.py index 45209ef0..4df80a74 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -929,7 +929,7 @@ class Message(object): def reply(self, msg, router=None, **kwargs): """ Compose a reply to this message and send it using :attr:`router`, or - `router` is :attr:`router` is :data:`None`. + `router` if :attr:`router` is :data:`None`. :param obj: Either a :class:`Message`, or an object to be serialized in order From 2403d4570bd124e636d82feca61f4619571d2a11 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 15 Jan 2026 14:35:14 +0000 Subject: [PATCH 2/2] mitogen: Format Message src & dst of as : The notation is inspired by host:port notation in a URL. In Mitogen context id and handles fill roughly the same role as IP and port in TCP or UDP. --- docs/changelog.rst | 2 ++ mitogen/core.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 95131afb..b08614c7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -34,6 +34,8 @@ v0.3.37 (2026-01-08) :py:class:`importlib.resource.abc.ResourceReader` protocol * :gh:issue:`1407` :mod:`mitogen`: Fix :exc:`AttributeError` in :mod:`mitogen.profiler` +* :gh:issue:`1418` :mod:`mitogen`: Format :class:`mitogen.core.Message` source + and destination as ``:``, for clarity v0.3.36 (2025-12-01) diff --git a/mitogen/core.py b/mitogen/core.py index 4df80a74..666905ca 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -1004,9 +1004,14 @@ class Message(object): return obj def __repr__(self): - return 'Message(%r, %r, %r, %r, %r, %r..%d)' % ( - self.dst_id, self.src_id, self.auth_id, self.handle, - self.reply_to, (self.data or '')[:50], len(self.data) + if len(self.data) > 60: + head, tail, size = self.data[:25], self.data[-25:], len(self.data) + data_summary = b('%s .. %s %d bytes') % (head, tail, size) + else: + data_summary = self.data + return 'Message(src=%r:%r dst=%r:%r auth_id=%r %r)' % ( + self.src_id, self.reply_to, self.dst_id, self.handle, self.auth_id, + data_summary, )