#13614: Python Bindings fails on Recorded.update() during silence detection
-----------------------------------+-------------------------------
Reporter: rcrdnalor | Owner: rcrdnalor
Type: Patch - Bug Fix | Status: assigned
Priority: minor | Milestone: needs_triage
Component: Bindings - Python | Version: v31-fixes
Severity: medium | Keywords: silence detection
Ticket locked: 0 |
-----------------------------------+-------------------------------
A user on the forum reported a traceback in the python bindings (1)
when running the detection for silence according the wiki page
"Commercial detection with silences" (2).
(1) https://forum.mythtv.org/viewtopic.php?f=36&t=3763
(2) https://www.mythtv.org/wiki/Commercial_detection_with_silences
This affects Ubuntu 20.04 for
- Python 3.8
- MySQLdb 1.4.4
- MariaDB 10.3
I had not any errors on Ubuntu 19.10 for
- Python 3.7
- MySQLdb 1.3.10
- MariaDB 10.3
The following traceback occurs when running silence.py with chanid
and starttime as paramters:
{{{
Traceback (most recent call last):
File "/home/local-admin/MythTV/silence/MythTV/_conn_mysqldb.py", line
98, in executemany
return super(LoggedCursor, self).executemany(query, args)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 235, in
executemany
return self._do_execute_many(q_prefix, q_values, q_postfix, args,
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 264, in
_do_execute_many
rows += self.execute(sql + postfix)
File "/home/local-admin/MythTV/silence/MythTV/_conn_mysqldb.py", line
68, in execute
query = self._sanitize(query)
File "/home/local-admin/MythTV/silence/MythTV/_conn_mysqldb.py", line
44, in _sanitize
def _sanitize(self, query): return query.replace('?', '%s')
TypeError: a bytes-like object is required, not 'str'
}}}
The offended call to 'MySQLdb.curser.execute' was
{{{
bytearray(b"INSERT INTO recordedmarkup (chanid,starttime,mark,type,data)
VALUES(10111,\'2020-02-09 16:10:00\',74367,4,NULL),(10111,\'2020-02-09
16:10:00\',81984,5,NULL)")
}}}
Note:
This is a callback from MySQLdb as described in a similar issue #13123.
MySQLdb resolves a call to 'executemany' to multiple calls of 'execute',
but as bytearray and not as string.
To reproduce this issue, one needs to patch the silence.py from the wiki
(2)
with the attached patch for python3 ('silence_py_patch_01.patch') and
install
it according the wiki page.
Then run 'silence.py -- chanid YYYY --starttime YYY' with correct
parameters.
To solve this issue, apply the path '0001_sanitize_mysql_queries.patch'
and, of course, the patch for 'silence.py'.
--
Ticket URL: <https://code.mythtv.org/trac/ticket/13614>
MythTV <http://www.mythtv.org>
MythTV Media Center
-----------------------------------+-------------------------------
Reporter: rcrdnalor | Owner: rcrdnalor
Type: Patch - Bug Fix | Status: assigned
Priority: minor | Milestone: needs_triage
Component: Bindings - Python | Version: v31-fixes
Severity: medium | Keywords: silence detection
Ticket locked: 0 |
-----------------------------------+-------------------------------
A user on the forum reported a traceback in the python bindings (1)
when running the detection for silence according the wiki page
"Commercial detection with silences" (2).
(1) https://forum.mythtv.org/viewtopic.php?f=36&t=3763
(2) https://www.mythtv.org/wiki/Commercial_detection_with_silences
This affects Ubuntu 20.04 for
- Python 3.8
- MySQLdb 1.4.4
- MariaDB 10.3
I had not any errors on Ubuntu 19.10 for
- Python 3.7
- MySQLdb 1.3.10
- MariaDB 10.3
The following traceback occurs when running silence.py with chanid
and starttime as paramters:
{{{
Traceback (most recent call last):
File "/home/local-admin/MythTV/silence/MythTV/_conn_mysqldb.py", line
98, in executemany
return super(LoggedCursor, self).executemany(query, args)
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 235, in
executemany
return self._do_execute_many(q_prefix, q_values, q_postfix, args,
File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 264, in
_do_execute_many
rows += self.execute(sql + postfix)
File "/home/local-admin/MythTV/silence/MythTV/_conn_mysqldb.py", line
68, in execute
query = self._sanitize(query)
File "/home/local-admin/MythTV/silence/MythTV/_conn_mysqldb.py", line
44, in _sanitize
def _sanitize(self, query): return query.replace('?', '%s')
TypeError: a bytes-like object is required, not 'str'
}}}
The offended call to 'MySQLdb.curser.execute' was
{{{
bytearray(b"INSERT INTO recordedmarkup (chanid,starttime,mark,type,data)
VALUES(10111,\'2020-02-09 16:10:00\',74367,4,NULL),(10111,\'2020-02-09
16:10:00\',81984,5,NULL)")
}}}
Note:
This is a callback from MySQLdb as described in a similar issue #13123.
MySQLdb resolves a call to 'executemany' to multiple calls of 'execute',
but as bytearray and not as string.
To reproduce this issue, one needs to patch the silence.py from the wiki
(2)
with the attached patch for python3 ('silence_py_patch_01.patch') and
install
it according the wiki page.
Then run 'silence.py -- chanid YYYY --starttime YYY' with correct
parameters.
To solve this issue, apply the path '0001_sanitize_mysql_queries.patch'
and, of course, the patch for 'silence.py'.
--
Ticket URL: <https://code.mythtv.org/trac/ticket/13614>
MythTV <http://www.mythtv.org>
MythTV Media Center