Opened 17 months ago

Closed 8 months ago

#3385 closed bug (Fixed)

TypeError: a bytes-like object is required, not 'str'

Reported by: fdge00 Owned by:
Priority: minor Milestone: 2.0.4
Component: Unknown Version: 2.0.3
Keywords: Cc:

Description

Python 3.7 libtorrent 1.2.5 boost 1.72 FreeBSD 11.3-RELEASE-p7 (FreeNAS.amd64)

Traceback (most recent call last):
  File "/home/deluge/.local/bin/deluged", line 11, in <module>
    load_entry_point('deluge==2.0.4.dev0', 'console_scripts', 'deluged')()
  File "/home/deluge/.local/lib/python3.7/site-packages/deluge-2.0.4.dev0-py3.7.egg/deluge/core/daemon_entry.py", line 87, in start_daemon
    options = parser.parse_args()
  File "/home/deluge/.local/lib/python3.7/site-packages/deluge-2.0.4.dev0-py3.7.egg/deluge/argparserbase.py", line 250, in parse_args
    return self._handle_ui_options(options)
  File "/home/deluge/.local/lib/python3.7/site-packages/deluge-2.0.4.dev0-py3.7.egg/deluge/argparserbase.py", line 329, in _handle_ui_options
    _file.write('%d\n' % os.getpid())
TypeError: a bytes-like object is required, not 'str'

changing the line to

_file.write(b'%d\n' % os.getpid())

allows it to get further, but then I get an OpenSSL error which I'll make another ticket for.

Change History (2)

comment:1 Changed 10 months ago by lyckeleb

SITUATION :

OS : Ubuntu 20.04.1 (xubuntu-desktop) PPA : "ppa:deluge-team/stable"

To start deluge as a daemon, I created a systemd service file "/etc/systemd/system/deluged.service" containing

ExecStart?=/usr/bin/deluged --port=56789 --do-not-daemonize --pidfile=/tmp/deluged.pid

This gives the fatal failure "TypeError?: a bytes-like object is required, not 'str'" on starting the service.


WORKAROUND :

Remove the "--pidfile=/tmp/deluged.pid" from ExecStart?.


CAUSE:

The file "/usr/lib/python3/dist-packages/deluge/argparserbase.py" contains

    326           # Write pid file before chuid
    327           if options.pidfile:
    328               with open(options.pidfile, 'wb') as _file:
    329                   _file.write('%d\n' % os.getpid())

Line 328 enforces BINARY WRITES to the PID-file. But a string will be written in line 329. This causes a write-error (and ultimately the fatal failure).


SOLUTION :

Change line 328 in

    328               with open(options.pidfile, 'w') as _file:

The 'wb' is changed in 'w'. :)

comment:2 Changed 8 months ago by Cas

  • Milestone changed from needs verified to 2.0.4
  • Resolution set to Fixed
  • Status changed from new to closed

This was fixed in [1b4ac88ce7]

Note: See TracTickets for help on using tickets.