Skip to content

Added fileno support to FakeOutput - #616

Merged
thomasballinger merged 1 commit into
bpython:masterfrom
calebstewart:add-fileno-to-fakeoutput
Jun 6, 2016
Merged

thomasballinger merged 1 commit into
bpython:masterfrom
calebstewart:add-fileno-to-fakeoutput

Conversation

@calebstewart

Copy link
Copy Markdown
Contributor

Some applications that use curses require that the object in sys.stdout be a file with the a method called fileno. In order to facilitate this, a fileno method was added to the FakeOutput object. An extra named parameter was added to the constructor as well to facilitate choosing the result of the fileno method. The default value is 1 (or standard output).

The two allocations of FakeOutput (for stderr and stdout) were also changed to specify the file number to be returned by fileno.

These additions do not effect any existing code, but allow users to import libraries such as pwntools while using bpython.

@calebstewart

Copy link
Copy Markdown
Contributor Author

This also fixes #612.

@thomasballinger
thomasballinger merged commit c2c9e84 into bpython:master Jun 6, 2016
@thomasballinger

Copy link
Copy Markdown
Member

Thanks @caleb1994. I guess now if a library writes to this file descriptor that we'll have display problems, but that seems better than the libs not being importable.

Note to myself: I wonder if putting a pipe there and letting things write to it and catching the data being written so we could integrate it would be useful? Would this break a lot of libs that expect a tty on stdout instead of a pipe?

@sebastinas

Copy link
Copy Markdown
Contributor

hrm, this has been rejected in the past for various reasons. Essentially since we have never figured out what it would mean to operate on the fileno.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants