Closed dimitriylol closed 7 years ago
The code that calls read
on a URLError
should only be executed on Python 3, so it's strange that you're getting that. In the ctrl-console, what does
import sys; sys.version_info[0]` return?
3rd version. It's weird, because I didn't change default 'python' symlink: /usr/bin/python -> python2.7. Obviously, it's my mistake. Do you need any additional information?
Apparently the Python doc's claim that a URLError is a stream isn't really accurate, and it isn't when it is caused by a connection problem rather than an error response. Attached patch should fix the error you got, but I don't know what caused the request failure -- if your server is running, it's odd that the HTTP request is failing on a connection issue. Maybe the new error message will shed some light.
After cloning new repo, I've got this error in console: Traceback (most recent call last): File "./python3.3/urllib/request.py", line 1248, in do_open File "./python3.3/http/client.py", line 1065, in request File "./python3.3/http/client.py", line 1103, in _send_request File "./python3.3/http/client.py", line 1061, in endheaders File "./python3.3/http/client.py", line 906, in _send_output File "./python3.3/http/client.py", line 844, in send File "./python3.3/http/client.py", line 822, in connect File "./python3.3/socket.py", line 435, in create_connection File "./python3.3/socket.py", line 426, in create_connection ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/dlyman/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 264, in f req = opener.open("http://" + localhost + ":" + str(port) + "/", json.dumps(doc).encode("utf-8"), 1) File "./python3.3/urllib/request.py", line 469, in open File "./python3.3/urllib/request.py", line 487, in _open File "./python3.3/urllib/request.py", line 447, in _call_chain File "./python3.3/urllib/request.py", line 1274, in http_open File "./python3.3/urllib/request.py", line 1251, in do_open urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/dlyman/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 320, in run_command data = make_request(port, doc) File "/home/dlyman/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 267, in f raise Req_Error((hasattr(error, "read") and error.read().decode("utf-8")) or error.reason) tern_for_sublime.tern.Req_Error During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/opt/sublime_text/sublimeplugin.py", line 818, in run return self.run(edit) File "/home/dlyman/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 521, in run data = run_command(self.view, {"type": "definition", "lineCharPositions": True}) File "/home/dlyman/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 322, in run_command if not silent: report_error(str(e), pfile.project) TypeError: str returned non-string (type ConnectionRefusedError)
How I can print localhost and port value or debug package in st3?
you can do import tern_for_sublime; tern_for_sublime.tern.localhost
to get at localhost
. Figuring out what port it is connecting to is harder. You could try adding a print
statement to the python script.
I don't know why, but print statement produces error.
I've add port and localhost values in error message instead of error.reason. I get correct values: port is
Thanks for quick response and sublime package for tern :)
Glad you figured it out.
127.0.1.1 localhost
I can't imagine where that came from, but you might want to delete it, since it'll break every single tool that assumes localhost points at the loopback network device.
I follow the instruction in Readme.md and install tern_for_sublime, but I get the error when I use tern actions: jump to definition, autocomplete. Here is error message 'URLError' object has no attribute 'read'. There are two options "Disable Tern" or "Cancel".
When I added tern_command options in Tern.sublime-settings, I saw that file .tern-port was created. There are two variants of tern_command, that I set: "tern_command": ["node", "/usr/local/bin/tern"] and "tern_command": ["node", "path/to/package/tern_for_sublime/node_modules/tern/bin/tern"].
OS: ubuntu Python version: Python 2.7.12