question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 5 years ago
  • Reactions:8
  • Comments:14

github_iconTop GitHub Comments

2reactions
Pomoinytskyicommented, Jul 18, 2018

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.

1reaction
gonzalocasascommented, Jul 5, 2018

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: image

Screenshot of the same code running on Windows’ cmd console: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 2.7 sometimes yields IOError: [Errno 0] Error on Windows
It appears as if the standard output was broken or handled incorrectly when running Python from inside a Hyper terminal. To me it...
Read more >
"IOError: [Errno 0] Error" error in Python - Stack Overflow
In f.seek(0,2) , 2 is the from_what argument. A from_what value of 0 measures from the beginning of the file, 1 uses the...
Read more >
Windows/2.7.15 IOError [Errno 0] when user interacts with cmd ...
Upon resuming, the following error is seen: Traceback (most recent call last): File "<stdin>", line 2, in <module> IOError: [Errno 0] Error.
Read more >
Issue 11395: print(s) fails on Windows with long strings
Python 3.2 fails when printing long strings. ... 2) 2.7.1 and 3.1.3 on Windows x64 are fine 3) The 32-bit interpreter for 3.2...
Read more >
Issue 4841: io's close() not handling errors correctly - Python tracker
In Python 2.x, internal_closes() returns the errno value of close() on error, or 0 on success. fileio_close() tests if the error value is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found