PythonOpenModule icon indicating copy to clipboard operation
PythonOpenModule copied to clipboard

Open Python module raises SyntaxError when python on PATH is Python 3 (print sys.path)

Open dpc00 opened this issue 1 month ago • 0 comments

Claude reports:

"Open Python module" fails with a SyntaxError whenever python on the PATH is Python 3, because the command it runs to get sys.path is Python 2 syntax.

Python Open Module (current master, copied into Packages; it is not offered in the Package Control list I use), Sublime Text build 4215, Windows, python on the PATH is 3.14. I ran python_open_module and entered decimal in the panel. Nothing opens, and the console shows:

  File ".../python_open_module.py", line 50, in get_user_syspath
    sys_path = eval(sys_path_str)
  File "<string>", line 0
SyntaxError: invalid syntax

get_user_syspath runs [python_executable, '-c', 'import sys; print sys.path']. With Python 3 that is a SyntaxError inside the child process, so stdout is empty and eval('') raises in the plugin. Only OSError is caught (python not found), so this is not handled.

Fix (not run): use print(sys.path) (valid in both), or better ask for JSON (import sys, json; print(json.dumps(sys.path)) and json.loads) instead of evaling the output.

dpc00 avatar Oct 25 '26 22:10 dpc00