You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is totally fine:
p = pexpect.spawn('env', env={"BLAH": "1"})
This hangs forever; note the int data type on the value
p = pexpect.spawn('env', env={"BLAH": 1})
Killing the above with ctrl+c I get:
p = pexpect.spawn('env', env={"BLAH": 1})
^CTraceback (most recent call last):
File "", line 1, in
File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 205, in init
self._spawn(command, args, preexec_fn, dimensions)
File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 303, in _spawn
self.ptyproc = self._spawnpty(self.args, env=self.env,
File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 315, in _spawnpty
return ptyprocess.PtyProcess.spawn(args, **kwargs)
File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/ptyprocess/ptyprocess.py", line 309, in spawn
exec_err_data = os.read(exec_err_pipe_read, 4096)
KeyboardInterrupt
As a somewhat distinct symptom, inside a script you can do:
b'Traceback (most recent call last):\r\n File "blah2.py", line 3, in <module>\r\n p = pexpect.spawn(\'env\', env={"BLAH": 1})\r\n File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 205, in __init__\r\n self._spawn(command, args, preexec_fn, dimensions)\r\n File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 303, in _spawn\r\n self.ptyproc = self._spawnpty(self.args, env=self.env,\r\n File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 315, in _spawnpty\r\n return ptyprocess.PtyProcess.spawn(args, **kwargs)\r\n File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/site-packages/ptyprocess/ptyprocess.py", line 285, in spawn\r\n os.execvpe(command, argv, env)\r\n File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/os.py", line 577, in execvpe\r\n _execvpe(file, args, env)\r\n File "/home/mbryan/.pyenv/versions/3.8.2/lib/python3.8/os.py", line 591, in _execvpe\r\n exec_func(file, *argrest)\r\nTypeError: expected str, bytes or os.PathLike object, not int\r\n'
So it seems that there is some sanitization down in the os lib to catch the bad data type, but that we've already borked ourselves before we get there, which means we never print the nastygram; we just exit. Meaning: that traceback should be printed back to the user; it shouldn't end up in the spawn's buffer!
Secondary request: it would be helpful to add some docs for the format of env while you are at it. Maybe there are some on readthedocs, but I'm not seeing them.
The text was updated successfully, but these errors were encountered:
Is there any reason why you would need an int for a value in that dictionary? If not, we could coerce all values inside env to type str. Though that could have unintended consequences. If this is intended behaviour (ie that value is always meant to be a string) then docs could be updated accordingly.
Would the coercion logic affect only the psudo-tty path, or the SSH and other paths as well?
I'm not sure how the data is handled at each layer down the stack, but I'm thinking the user could do something like "1" for an unquoted value, and ""1"" for a quoted value, in theory. But I'm not sure how escaping happens (or doesn't) at lower layers. Do you know? I don't know enough to say.
Minimal repro:
In an interactive interpreter:
This is totally fine:
p = pexpect.spawn('env', env={"BLAH": "1"})
This hangs forever; note the int data type on the value
p = pexpect.spawn('env', env={"BLAH": 1})
Killing the above with ctrl+c I get:
As a somewhat distinct symptom, inside a script you can do:
You get:
So it seems that there is some sanitization down in the os lib to catch the bad data type, but that we've already borked ourselves before we get there, which means we never print the nastygram; we just exit. Meaning: that traceback should be printed back to the user; it shouldn't end up in the spawn's buffer!
Secondary request: it would be helpful to add some docs for the format of env while you are at it. Maybe there are some on readthedocs, but I'm not seeing them.
The text was updated successfully, but these errors were encountered: