[Deluge] #3385: TypeError: a bytes-like object is required, not 'str'

7 views
Skip to first unread message

Deluge

unread,
Apr 18, 2020, 6:57:24 AM4/18/20
to delug...@googlegroups.com
#3385: TypeError: a bytes-like object is required, not 'str'
----------------------------+---------------------
Reporter: fdge00 | Type: bug
Status: new | Priority: minor
Milestone: needs verified | Component: Unknown
Version: 2.0.3 | Keywords:
----------------------------+---------------------
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.

--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3385>
Deluge <https://deluge-torrent.org/>
Deluge Project

Deluge

unread,
Dec 8, 2020, 7:49:00 AM12/8/20
to delug...@googlegroups.com
#3385: TypeError: a bytes-like object is required, not 'str'
----------------------+----------------------------
Reporter: fdge00 | Owner:

Type: bug | Status: new
Priority: minor | Milestone: needs verified
Component: Unknown | Version: 2.0.3
Resolution: | Keywords:
----------------------+----------------------------

Comment (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'. :)

--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3385#comment:1>

Deluge

unread,
Feb 5, 2021, 3:39:47 PM2/5/21
to delug...@googlegroups.com
#3385: TypeError: a bytes-like object is required, not 'str'
----------------------+--------------------
Reporter: fdge00 | Owner:
Type: bug | Status: closed
Priority: minor | Milestone: 2.0.4
Component: Unknown | Version: 2.0.3
Resolution: Fixed | Keywords:
----------------------+--------------------
Changes (by Cas):

* status: new => closed
* resolution: => Fixed
* milestone: needs verified => 2.0.4


Comment:

This was fixed in [1b4ac88ce7]

--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3385#comment:2>

Reply all
Reply to author
Forward
0 new messages