vercel / vercel/hyper

Python 2.7 sometimes yields IOError: [Errno 0] Error on Windows

Open
#2,822 14 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🤯 Type: Compatibility
Dominant language
TypeScript
Stars
44.7k
Forks
3.6k
Avg merge
21m
Merged PRs (30d)
1

Description

  • 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure in Hyper.app on Windows with Python 2.7 using the test.py loop shown in the issue, then compare it with the other terminals mentioned. Trace how Hyper handles console output during repeated writes and verify the issue is resolved when the script completes without IOError: [Errno 0] Error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.