Package: python-daemon Version: 2.0.5-1 Severity: important Tags: patch If you initialise DaemonContext with a signal_map as documented you get the following:
>>> import daemon, signal
>>> with daemon.DaemonContext(signal_map={signal.SIGTERM: 'terminate'}):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/daemon/daemon.py", line 380, in
__enter__
self.open()
File "/usr/lib/python2.7/dist-packages/daemon/daemon.py", line 362, in open
set_signal_handlers(signal_handler_map)
File "/usr/lib/python2.7/dist-packages/daemon/daemon.py", line 883, in
set_signal_handlers
signal.signal(signal_number, handler)
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable
object
As a workaround, you can pass a unicode string (u'terminate').
The attached patch uses basestring instead of unicode for comparison
which ensures that the correct terminate handler is installed as
documented.
-- System Information:
Debian Release: stretch/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages python-daemon depends on:
ii python-docutils 0.12+dfsg-1
ii python-lockfile 1:0.10.2-2
ii python-pkg-resources 17.0-1
pn python:any <none>
python-daemon recommends no packages.
python-daemon suggests no packages.
-- no debconf information
--
-- arthur - [email protected] - http://people.debian.org/~adejong --
Description: fix handling of signal_map values This fixes the case where a non-unicode 'termniate' string is passed via the signal_map argument to the DaemonContext constructor. The reason this appears to work in the tests is due to from __future__ import unicode_literals Author: Arthur de Jong <[email protected]> --- a/daemon/daemon.py +++ b/daemon/daemon.py @@ -483,7 +483,7 @@ class DaemonContext: """ if target is None: result = signal.SIG_IGN - elif isinstance(target, unicode): + elif isinstance(target, basestring): name = target result = getattr(self, name) else:
signature.asc
Description: This is a digitally signed message part

