-
-
Notifications
You must be signed in to change notification settings - Fork 0
BUG: Changed demjson to demjson3 to solve demjons installing problem
#14
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
Conversation
demjson does not support python3
|
I think demjson does support python3. Though it is good to keep the package up to date. Any reason we want to use demjson3 over the standard json library of python? |
Talking about demjson, the "og" demjson uses "DICT.has_key" which doesn't exist in python3 (python plugins that I have ported from Wox didn't work for me so I had to manually patch the flowlauncher package and install demjson3 myself). |
|
@mrmetrix4 I will check this new changing at today night. Lately, I'm kind of busy. |
Is there a specific plugin?
The standard json lib can't handle empty inputting. Flow.Launcher.JsonRPC.Python/flowlauncher/FlowLauncher.py Lines 20 to 21 in 89f6ca6
In [1]: import json
In [2]: json.loads("")
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 json.loads("")
File C:\Software\miniforge3\lib\json\__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
341 s = s.decode(detect_encoding(s), 'surrogatepass')
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
348 cls = JSONDecoder
File C:\Software\miniforge3\lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
332 def decode(self, s, _w=WHITESPACE.match):
333 """Return the Python representation of ``s`` (a ``str`` instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
File C:\Software\miniforge3\lib\json\decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0) |
Well, as so far I don't mind replace |
No, just some that I have coded for QoL in my work.
I wanted to install the package in order to show you but with Py3.10 I cant even get it: C:\Users\mrmet>pip install flowlauncher --no-cache-dir
Defaulting to user installation because normal site-packages is not writeable
Collecting flowlauncher
Downloading flowlauncher-0.1.1-py3-none-any.whl (4.6 kB)
Collecting demjson
Downloading demjson-2.2.4.tar.gz (131 kB)
---------------------------------------- 131.5/131.5 KB 969.7 kB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in demjson setup command: use_2to3 is invalid.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details. |
Iv'e done some testings, the latest version that works with demjson is 3.8.10. |
demjson can't either (3 or the original) -> # With original
import demjson
demjson.decode("")
# Error
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
demjson.decode("")
File "C:\Users\mrmet\AppData\Roaming\FlowLauncher\Plugins\Hello World Python-1.0.0\lib\demjson.py", line 5696, in decode
result = j.decode( txt,
File "C:\Users\mrmet\AppData\Roaming\FlowLauncher\Plugins\Hello World Python-1.0.0\lib\demjson.py", line 4915, in decode
raise errors[0]
demjson.JSONDecodeError: No value to decode
# With 3
import demjson3
demjson3.decode("")
# Error
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
demjson3.decode("")
File "C:\Users\mrmet\AppData\Roaming\Python\Python310\site-packages\demjson3.py", line 6423, in decode
result = j.decode(
File "C:\Users\mrmet\AppData\Roaming\Python\Python310\site-packages\demjson3.py", line 5607, in decode
raise errors[0]
demjson3.JSONDecodeError: No value to decode |
|
The core problem is setuptools already removes lib2to3 from version 58.0.0. |
Cool, so I see two possibilities:
Do you want me to write a poc using the native json lib? |
I've done it anyway, works well for me: |
|
Well, it took a little time to find out the reason why use
|
|
The empty string is the answer to handle this line problem from original source wox.py. To avoid empty inputting.
|
That's not a problem, that's by design. JSON should not contain single quotes.
So this if statement fixes it without being a problem, isn't it? |
|
We use standard json lib to create the json input, so it shouldn't contain ' anymore. |
Therefore, please consider merging #15 in. |
|
JSON should not contain single quotes. It's right as a protocol. But it's also hard to constrict the inputting from the user. Another solution is to drop
Flow.Launcher.JsonRPC.Python/flowlauncher/FlowLauncher.py Lines 31 to 32 in aa145ff
|
|
Because that's how flow currently pass in the query information (by sys.argv). |
Agree, |
demjson to demjson3 to solve demjons installing problem
|
It could use |
demjson does not support python3.