-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt to use json.load(fd) again #624
Conversation
48a80c7
to
0d5d0c8
Compare
This PR includes: - Use json.load(fdesc) - Early exit in tokenresolver
I moved the non-Kodi-specific stuff (which was caching-related) to utils.py. |
eb0d48f
to
3d78747
Compare
I'm okay with rearranging functionality in different utils files. I got the following error with 85d065a on Python 3:
So, I think we need to catch |
I don't think so, I cannot split it up as I envisioned because of circular dependencies. |
The integration tests did not fail for this, so it ought to work. What Python version is this? Update: The only hits I get on |
The error does not make sense and is not something we can do anything about anyway. I wonder if you have somewhere old .pyc files lying around that may be redefining ValueError, or something like that. If you distribute using ZIP files that can't happen, but if you copy over files, you may accidentally leave behind .pyc or .pyo or pycache files. class JSONDecodeError(ValueError):
"""Subclass of ValueError with the following additional properties:
msg: The unformatted error message
doc: The JSON document being parsed
pos: The start index of doc where parsing failed
lineno: The line corresponding to pos
colno: The column corresponding to pos
"""
# Note that this exception is used from _json
def __init__(self, msg, doc, pos):
lineno = doc.count('\n', 0, pos) + 1
colno = pos - doc.rfind('\n', 0, pos)
errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
ValueError.__init__(self, errmsg)
self.msg = msg
self.doc = doc
self.pos = pos
self.lineno = lineno
self.colno = colno
def __reduce__(self):
return self.__class__, (self.msg, self.doc, self.pos) |
I got this error with the built-in Python 3 in Kodi 19.0-ALPHA1 Git:20191205-b238c23acc for Windows x64 |
I got the same error again on a clean Kodi install: 19.0-ALPHA1 Git:20191209-923cfade46 |
What python version is this? We test almost the entire codebase (including these routines) against 3.5, 3.6, 3.7 and 3.8. Could you copy the above definition of the JSONDecodeError class from this Python here ? I would say that Python is severely broken. It is contradicting itself, which is only possible if ValueError was somehow deleted during operation ( I get the same error if I do: #!/usr/bin/python
import json
del __builtins__.ValueError
raise json.JSONDecodeError(doc='', msg='', pos=3) results in: [dag@moria plugin.video.vrt.nu]$ python3 test.py
Traceback (most recent call last):
File "test.py", line 7, in <module>
raise json.JSONDecodeError(doc='', msg='', pos=3)
File "/usr/lib64/python3.6/json/decoder.py", line 35, in __init__
ValueError.__init__(self, errmsg)
NameError: name 'ValueError' is not defined |
This PR includes: - Use json.load(fdesc) - Early exit in tokenresolver - Move caching functionality to utils.py - Fix 2 issues - Return default value on failure - Fix more json.load() calls for Python 3.5
It should be Python 3.7 (xbmc/xbmc@61f40ea) class JSONDecodeError(ValueError):
"""Subclass of ValueError with the following additional properties:
msg: The unformatted error message
doc: The JSON document being parsed
pos: The start index of doc where parsing failed
lineno: The line corresponding to pos
colno: The column corresponding to pos
"""
# Note that this exception is used from _json
def __init__(self, msg, doc, pos):
lineno = doc.count('\n', 0, pos) + 1
colno = pos - doc.rfind('\n', 0, pos)
errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
ValueError.__init__(self, errmsg)
self.msg = msg
self.doc = doc
self.pos = pos
self.lineno = lineno
self.colno = colno
def __reduce__(self):
return self.__class__, (self.msg, self.doc, self.pos) |
So I think this is ready to be merged. The reported |
You can merge this as this is an improvement and doesn't break things.
Userdata was definitely removed, I reconfigured VRT NU add-on, activated debug logging again, etc...it really was a clean Kodi install. I suspect the I can reproduce this error when starting and stopping episodes quickly after each other. |
@mediaminister Ok, I believe you. Then the less (now most) probable cause is a bug (or at least an incompatibility) in the Python version of Kodi 19 related to A minimal reproducer will probably convince developers, but if you report this I expect disbelieve and expecting a user-problem (like me :-)). It would explain why we do not see this in our integration tests. What could also help, is recursively grepping the code for "ValueError" (and anything causing it to become undefined briefly when e.g. reloading something). |
PS I doubt this is |
I tried to reproduce this on a Windows 10 laptop using Kodi 19.0-ALPHA1 Git_20191018 and I couldn't reproduce the reported issue, but I managed to make Kodi crash after 7 successive playbacks of Terzake episodes 🙄 Now going to upgrade to test again. |
@mediaminister I cannot reproduce this with Kodi 19.0-ALPHA1 64bit Git_20191209, can you provide more detailed instructions? |
Steps to reproduce:
Repeat the steps in 2. until you get an error. |
Would probably be the easiest to disable |
I tried that a lot. But ending video playback usually takes a second or more, so it's hard to actually play them with little delay. Maybe it is easier using the JSONRPC interface? |
I cannot reproduce this. The fastest way to play streams is by adding a folder to the playlist (press Q on a folder, e.g. TerZake) and then you can select new video's without having to leave the listing. |
Okay, nevermind, I just tested this in Virtualbox, I'll open a new issue if I can reliably reproduce this on another (Windows) system. |
This PR includes:
This fixes #554
This relates to #385