[Python-modules-team] Bug#863600: python3-twisted: cannot cancel a DelayedCall (fixed in upstream)

Goetz, Philippe Philippe.Goetz at siemens.com
Mon May 29 05:02:34 UTC 2017


Package: python3-twisted
Version: 16.6.0-2
Severity: important

Dear Maintainer,

Under stretch (and sid twisted=17.1.0), it is not possible to cancel a DelayedCall in python3:
    p.cancel()
  File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 96, in cancel
    self._str = bytes(self)
TypeError: 'DelayedCall' object is not iterable

This is fixed in upstream from https://github.com/twisted/twisted.git:

$ git show 5a5e5ca33b2a552ae2ca91e5dd38bd75e07306ff
commit 5a5e5ca33b2a552ae2ca91e5dd38bd75e07306ff
Author: Craig Rodrigues <rodrigc at FreeBSD.org>
Date:   Sat Jan 14 19:55:09 2017 -0800

    DelayedCall needs to call str(self), not bytes(self) to work on Python 3

diff --git a/src/twisted/internet/base.py b/src/twisted/internet/base.py
index 3e1c63cbf..fbb7619b8 100644
--- a/src/twisted/internet/base.py
+++ b/src/twisted/internet/base.py
@@ -101,7 +101,7 @@ class DelayedCall:
             self.canceller(self)
             self.cancelled = 1
             if self.debug:
-                self._str = bytes(self)
+                self._str = str(self)
             del self.func, self.args, self.kw

     def reset(self, secondsFromNow):
diff --git a/src/twisted/internet/test/test_base.py b/src/twisted/internet/test/test_base.py
index ba6964a40..7fee2004e 100644
--- a/src/twisted/internet/test/test_base.py
+++ b/src/twisted/internet/test/test_base.py
@@ -183,6 +183,7 @@ class DelayedCallTests(TestCase):
         Create two L{DelayedCall} instanced scheduled to run at different
         times.
         """
+        self.patch(DelayedCall, 'debug', True)
         self.zero = self._getDelayedCallAt(0)
         self.one = self._getDelayedCallAt(1)

@@ -193,6 +194,7 @@ class DelayedCallTests(TestCase):
         C{str}, includes the unsigned id of the instance, as well as its state,
         the function to be called, and the function arguments.
         """
+        DelayedCall.debug = False
         dc = DelayedCall(12, nothing, (3, ), {"A": 5}, None, None, lambda: 1.5)
         self.assertEqual(
             str(dc),

With best regards,
Philippe Goetz

Siemens AG
Building Technologies Division
Solution and Service Portfolio
Danger Management System
BT SSP SOL R&D CI DMS
Siemensallee 84
76187 Karlsruhe, Germany 
mailto:philippe.goetz at siemens.com

Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme; Managing Board: Joe Kaeser, Chairman, President and Chief Executive Officer; Roland Busch, Lisa Davis, Klaus Helmrich, Janina Kugel, Cedrik Neike, Michael Sen, Ralf P. Thomas; Registered offices: Berlin and Munich, Germany; Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684; WEEE-Reg.-No. DE 23691322



More information about the Python-modules-team mailing list