joelspadin / pyvswhere

Python interface to Microsoft's Visual Studio locator tool, vswhere
MIT License
10 stars 2 forks source link

TypeError: the JSON object must be str, not 'bytes' #1

Closed ijuedt closed 5 years ago

ijuedt commented 5 years ago

Connected to pydev debugger (build 191.7479.30) Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\pydev\pydevd.py", line 1758, in main() File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\pydev\pydevd.py", line 1752, in main globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\pydev\pydevd.py", line 1147, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/GITREP/PyUnitTest/VSTestDeployment.py", line 37, in print(has_vstest()) File "C:/GITREP/PyUnitTest/VSTestDeployment.py", line 20, in has_vstest result = vswhere.get_latest() File "C:\GITREP\PyUnitTest\vswhere.py", line 132, in get_latest return find_first(latest=True, legacy=True) File "C:\GITREP\PyUnitTest\vswhere.py", line 125, in find_first return next(iter(find(**kwargs)), None) File "C:\GITREP\PyUnitTest\vswhere.py", line 116, in find return execute(args) File "C:\GITREP\PyUnitTest\vswhere.py", line 52, in execute return json.loads(output, encoding='utf-8') File "C:\Users\ingjuedt\AppData\Local\Programs\Python\Python35-32\lib\json__init.py", line 312, in loads s.class.name__)) TypeError: the JSON object must be str, not 'bytes'

Process finished with exit code -1

ijuedt commented 5 years ago

Replacing "return json.loads(output, encoding='utf-8')" by "return json.loads(str(output, 'utf-8'), encoding='utf-8')" in line 52 does the fix.

joelspadin commented 5 years ago

Oh. I think I'd only tested this with Python 2.7, so there was probably a change in what subprocess.check_output returns from str to bytes.

Thanks for the potential fix. I'll check that it works on both Python 2 and 3.

joelspadin commented 5 years ago

Thanks for the report! I've updated the PyPI package to version 1.1.2. Let me know if you still have any problems with it.