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
{{ message }}
Repository navigation
Pythonista 3.5: Does not reset stdin/stdout/stderr on new script execution #792
If some script change sys.stdout, sys.stderr, sys.stdin on runtime, there are no reset to original ones on second and future scripts executions. All next executions will use redefined IO, in some cases it won't print nothing. The only way to fix it is reload sys module or restart the app.
Is there way to setup force sys/interpreter/environment reset on next script execution? For now I can avoid it just with adding shortcut to the script with reset environment flag
This behaviour can be represented with this small snippets
Run script1.py and then script2.py
# script1.pyimportsysclassFakeStream:
defwrite(self, s, no_wait=False):
pass# assume this stream have no outputprint("sample text 1") # output: sample text 1sys.stdout=FakeStream()
print("sample text 2") # No output there
# script2.pyprint("sample text 3") # No more output there till `sys` reload or Pythonista restart
P.S.: For example it happen every time the StaSh launched. It overwrites sys and then neither ansi escape codes will work in the console
changed the title [-]Pythonista 3.5: Does not reset `stdit/stdout/stderr` on new script execution[/-][+]Pythonista 3.5: Does not reset `stdin/stdout/stderr` on new script execution[/+]on Aug 19, 2025
I guess, being able to overwrite stdout across script launches could be seen as a feature (for customizing Pythonista's output), but in most cases, it would probably make sense to always reset stdout/stderr to the default streams.
I guess, being able to overwrite stdout across script launches could be seen as a feature (for customizing Pythonista's output), but in most cases, it would probably make sense to always reset stdout/stderr to the default streams.
I would suggest making this feature optional in the settings. But this possibility must be present.
Activity
[-]Pythonista 3.5: Does not reset `stdit/stdout/stderr` on new script execution[/-][+]Pythonista 3.5: Does not reset `stdin/stdout/stderr` on new script execution[/+]omz commentedon Aug 29, 2025
Good point!
I guess, being able to overwrite stdout across script launches could be seen as a feature (for customizing Pythonista's output), but in most cases, it would probably make sense to always reset stdout/stderr to the default streams.
o-murphy commentedon Aug 29, 2025
I would suggest making this feature optional in the settings. But this possibility must be present.
o-murphy commentedon Aug 29, 2025
This is interesting, but not relevant to this issue discussion subject.