[GH-ISSUE #176] Exception while execute topic: unsupported operand type(s) for %: 'bytes' and 'tuple' #128

Closed
opened 2026-10-13 19:49:12 +00:00 by bsakaguchi · 5 comments
Owner

Originally created by @Clerik-owl on GitHub (Jan 13, 2017).
Original GitHub issue: https://github.com/werwolfby/monitorrent/issues/176

Про проверке раздач на рутрекере возникает ошибка.

INFO
Begin execute
INFO
Start checking for rutracker.org
INFO
Credentials/Settings are valid
INFO
Check for changes Однажды в Сказке / Once Upon a Time / Сезон: 5 / Серии: 1-23 из 23 (Ральф Хемекер, Рон Андервуд) [2015, США, Фэнтези, мелодрама, приключения, WEB-DL 720p] Dub (Невафильм) + Original + Subs (Rus, Eng)
FAILED
Exception while execute topic: unsupported operand type(s) for %: 'bytes' and 'tuple'
INFO
End checking for rutracker.org
INFO
End execute

Linux 4.7.0-0.bpo.1-amd64 #1 SMP Debian 4.7.8-1~bpo8+1 (2016-10-19) x86_64 GNU/Linux.
запущен из сорс кода "как есть".
debian jessie

Originally created by @Clerik-owl on GitHub (Jan 13, 2017). Original GitHub issue: https://github.com/werwolfby/monitorrent/issues/176 Про проверке раздач на рутрекере возникает ошибка. ``` INFO Begin execute INFO Start checking for rutracker.org INFO Credentials/Settings are valid INFO Check for changes Однажды в Сказке / Once Upon a Time / Сезон: 5 / Серии: 1-23 из 23 (Ральф Хемекер, Рон Андервуд) [2015, США, Фэнтези, мелодрама, приключения, WEB-DL 720p] Dub (Невафильм) + Original + Subs (Rus, Eng) FAILED Exception while execute topic: unsupported operand type(s) for %: 'bytes' and 'tuple' INFO End checking for rutracker.org INFO End execute ``` Linux 4.7.0-0.bpo.1-amd64 #1 SMP Debian 4.7.8-1~bpo8+1 (2016-10-19) x86_64 GNU/Linux. запущен из сорс кода "как есть". debian jessie
bsakaguchi 2026-10-13 19:49:12 +00:00
Author
Owner

@werwolfby commented on GitHub (Jan 15, 2017):

Python 3.4.2

<!-- gh-comment-id:272710457 --> @werwolfby commented on GitHub (Jan 15, 2017): > Python 3.4.2
Author
Owner

@werwolfby commented on GitHub (Jan 15, 2017):

Issue stacktrace:

FAILED
Exception while execute
Traceback (most recent call last):
File "/opt/monitorrent/monitorrent/plugins/trackers/lostfilm.py", line 575, in execute
TopicSettings.from_topic(topic))
File "/opt/monitorrent/monitorrent/engine.py", line 315, in add_torrent
return self.engine.add_torrent(filename, torrent, old_hash, topic_settings)
File "/opt/monitorrent/monitorrent/engine.py", line 83, in add_torrent
existing_torrent = self.clients_manager.find_torrent(torrent.info_hash)
File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 296, in info_hash
info_data = encode_dictionary(self.content['info'])
File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 176, in encode_dictionary
encoded += bencode(key)
File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 194, in bencode
return encode_functype(data)
File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 156, in encode_unicode
return encode_string(data.encode('utf8'))
File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 152, in encode_string
return b"%d:%s" % (len(data), data)
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
<!-- gh-comment-id:272710739 --> @werwolfby commented on GitHub (Jan 15, 2017): Issue stacktrace: ``` FAILED Exception while execute Traceback (most recent call last): File "/opt/monitorrent/monitorrent/plugins/trackers/lostfilm.py", line 575, in execute TopicSettings.from_topic(topic)) File "/opt/monitorrent/monitorrent/engine.py", line 315, in add_torrent return self.engine.add_torrent(filename, torrent, old_hash, topic_settings) File "/opt/monitorrent/monitorrent/engine.py", line 83, in add_torrent existing_torrent = self.clients_manager.find_torrent(torrent.info_hash) File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 296, in info_hash info_data = encode_dictionary(self.content['info']) File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 176, in encode_dictionary encoded += bencode(key) File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 194, in bencode return encode_functype(data) File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 156, in encode_unicode return encode_string(data.encode('utf8')) File "/opt/monitorrent/monitorrent/utils/bittorrent.py", line 152, in encode_string return b"%d:%s" % (len(data), data) TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple' ```
Author
Owner

@werwolfby commented on GitHub (Jan 15, 2017):

Behavior for python 3.4 and python 3.5 is differ:

Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> data = '123123'
>>> b"%d:%s" % (len(data), data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
>>> exit()

C:\Python35>python.exe
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> data = '123123'
>>> b"%d:%s" % (len(data), data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: %b requires bytes, or an object that implements __bytes__, not 'str'
<!-- gh-comment-id:272710788 --> @werwolfby commented on GitHub (Jan 15, 2017): Behavior for python 3.4 and python 3.5 is differ: ``` Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> data = '123123' >>> b"%d:%s" % (len(data), data) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple' >>> exit() C:\Python35>python.exe Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> data = '123123' >>> b"%d:%s" % (len(data), data) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: %b requires bytes, or an object that implements __bytes__, not 'str' ```
Author
Owner

@werwolfby commented on GitHub (Jan 15, 2017):

Проблема явно была в питоне 3.4:

C:\Python34>python.exe
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> data = b'123123'
>>> b"%d:%s" % (len(data), data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
>>> exit()

C:\Python35>python.exe
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> data = b'123123'
>>> b"%d:%s" % (len(data), data)
b'6:123123'
>>> exit()
<!-- gh-comment-id:272710880 --> @werwolfby commented on GitHub (Jan 15, 2017): Проблема явно была в питоне 3.4: ``` C:\Python34>python.exe Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> data = b'123123' >>> b"%d:%s" % (len(data), data) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple' >>> exit() C:\Python35>python.exe Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> data = b'123123' >>> b"%d:%s" % (len(data), data) b'6:123123' >>> exit() ```
Author
Owner

@werwolfby commented on GitHub (Jan 15, 2017):

Изменение 267ee18f9d пофиксало проблему

<!-- gh-comment-id:272711505 --> @werwolfby commented on GitHub (Jan 15, 2017): Изменение 267ee18f9d18e3607329eaea4ead707d57718af2 пофиксало проблему
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
werwolfby/monitorrent#128
No description provided.