Python 2.7 sometimes yields IOError: [Errno 0] Error on Windows
See original GitHub issue- OS version and name: Windows 10 64-bit
- Hyper.app version: 1.4.8 (stable)
- The issue is reproducible in vanilla Hyper.app: Yes
Issue
Printing to the console with Python 2 sometimes results in an IOError: [Errno 0]
on Windows. This issue seems to appear only on Windows when opening a file for both reading and writing, quote:
When the “r+”, “w+”, or “a+” access type is specified, both reading and writing are allowed (the file is said to be open for “update”). However, when you switch between reading and writing, there must be an intervening fflush, fsetpos, fseek, or rewind operation. The current position can be specified for the fsetpos or fseek operation, if desired.
Relevant StackOverflow answer here.
Running this script almost certainly causes the error at some point:
# py -2.7 test.py
for i in range(5000):
print('foo')
Output:
[...]
foo
foo
fTraceback (most recent call last):
File "test.py", line 5, in <module>
print('foo')
IOError: [Errno 0] Error
I am using Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32. I can not reproduce this with any other terminal (tested Windows default terminal & ConEmu).
It appears as if the standard output was broken or handled incorrectly when running Python from inside a Hyper terminal. To me it seems this must have a root cause unrelated to Python. When that cause is found, feel free to rename the title of this issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:14
Top GitHub Comments
Maybe it would be helpful or direct you in right way. I had similar problem with Python 2.7 which i tried to debug in VS Code. Problem was in using Integrated terminal. VS Code uses it by default. I disabled it in launch configuration file. I has parameter configurations/console which can be “none”, “integratedTerminal” and “externalTerminal”. Using “none” or "externalTerminal"solves the problem.
I can reproduce consistently on Hyper: 2.0.0 (stable), Plugins: none, OS: Windows 10, Python: 2.7. It does NOT happen on Python 3.6 for whatever reason.
The issue is triggered by the frequency of writes. The same test code with a
sleep(0.08)
inside the loop works for me. At first I thought this was a weird issue with my code, but I’ve eventually realized it’s a problem in Hyper and one that is actually quite critical and forces me not to use it from time to time.The exact same code works on
cmd
.Screenshot of the code running on a hyper console:
Screenshot of the same code running on Windows’ cmd console: