Skip to content
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

SublimeREPL broken, due invalid handle error when calling subprocess.Popen().poll() #6091

Closed
deathaxe opened this issue Aug 11, 2023 · 5 comments

Comments

@deathaxe
Copy link
Collaborator

Description of the bug

Latest dev builds (ST4153/4154) break SublimeREPL package. I just had a hard time trying to reproduce a users error, because sending text to a REPL failed with WinError 6.

Exactly the same procedure works in ST4143. (Haven't checked 4152)

Steps to reproduce

  1. Setup a new portable ST instance (SAFE MODE is not possible as SublimeREPL needs restart)
  2. Install Package Control
  3. Install SublimeREPL
  4. Restart ST
  5. Call "SublimeREPL: Python" from command palette (python must be installed and accessible via path)
  6. Create a dummy.py with a single line print("me") and save it.
  7. With that file focused hit ctrl+,, f key sequence to send file content to the repl.

Expected behavior

  1. Content of the debug.py is executed.
  2. REPL displays result.

That's what ST4143 does.

Actual behavior

ST4153/54 however displays a WinError 6, while checking for alive interpreters.

Traceback (most recent call last):
  File "C:\Apps\Sublime Text 4153\Lib\python33\sublime_plugin.py", line 1488, in run_
    return self.run(edit, **args)
  File "C:\Apps\Sublime Text 4153\Data\Packages\SublimeREPL\text_transfer.py", line 141, in run
    for rv in manager.find_repl(external_id):
  File "C:\Apps\Sublime Text 4153\Data\Packages\SublimeREPL\sublimerepl.py", line 470, in find_repl
    if not (rv.repl and rv.repl.is_alive()):
  File "C:\Apps\Sublime Text 4153\Data\Packages\SublimeREPL\repls\subprocess_repl.py", line 209, in is_alive
    return self.popen.poll() is None
  File "./python3.3/subprocess.py", line 930, in poll
  File "./python3.3/subprocess.py", line 1145, in _internal_poll
OSError: [WinError 6] Das Handle ist ungültig

I can however successfully call the following in ST's console:

>>> import subprocess;p = subprocess.Popen(["python"], bufsize=0, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, stdout=subprocess.PIPE); p.poll()

Sublime Text build number

4153

Operating system & version

Windows 11

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

@keith-hall
Copy link
Collaborator

keith-hall commented Aug 11, 2023

I can however successfully call the following in ST's console:

Just to clarify, is that working using both Python 3.3 and Python 3.8 hosts? Or is it a bug in just the Python 3.3 host?

@deathaxe
Copy link
Collaborator Author

Behavior is equal on both python 3.3 and 3.8.

Sending text fails due to failed poll regardless, which plugin_host runs SublimeREPL.

Console command works on both.

Also note, that sending text and evaluating works as expected if replacing return self.popen.poll() is None by return True in is_alive()

The interpreter itself is alive and the Popen() object is healthy. It's just the poll(), which fails.

@BenjaminSchaaf
Copy link
Member

Looks like SublimeREPL has a custom subprocess.Popen derived class that relies on some python internals. Some things related to file handles have been changed for 3.3 although subprocess.py was left untouched.

I had a look through the difference between 3.8.8 and 3.8.12 in relation to subprocess and file handles and there isn't anything that jumps out. I'd be surprised if it didn't have the same issue in 3.8.8 and earlier versions of 3.8.

@deathaxe
Copy link
Collaborator Author

Looks like SublimeREPL will remain broken then. It looks rather unmaintained.

@deathaxe
Copy link
Collaborator Author

Looking over PRs it appears this issue has already hit someone earlier.

wuub/SublimeREPL#577 fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants