[issue28864] Add devnull file-like object

2018-01-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: Closed due to lack of interest (I still think Python would be better-off with this feature). -- resolution: -> later stage: -> resolved status: open -> closed ___ Python tracker

[issue28864] Add devnull file-like object

2017-01-02 Thread Martin Panter
Martin Panter added the comment: Example where an implementation like Serhiy’s was not good enough: . In that case, the lack of flush() method causes a subtle problem. -- ___ Python tracker

[issue28864] Add devnull file-like object

2016-12-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: Which begs the question: what's the point? As David said, `open(os.devnull)` is a reasonably obvious way to do it. Is there a use case that it doesn't satisfy? -- ___ Python tracker

[issue28864] Add devnull file-like object

2016-12-05 Thread Christian Heimes
Christian Heimes added the comment: It can be done with some extra effort. We have to get the st_dev and st_inode from os.fstat(fd), cache them together with the fd, and verify them every time we create a new DevNull object. That way we catch both closed fd and modified fd. We might have to

[issue28864] Add devnull file-like object

2016-12-05 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___

[issue28864] Add devnull file-like object

2016-12-05 Thread Josh Rosenberg
Josh Rosenberg added the comment: Didn't pre-opened (or lazily opened) file descriptors cause headaches with os.urandom? I'm not sure I'd want my programming environment eating file descriptors "just in case", even if it might make certain tasks trivially faster after startup. --

[issue28864] Add devnull file-like object

2016-12-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: I had in mind a pre-opened file like sys.stderr or sys.stdout. -- ___ Python tracker ___

[issue28864] Add devnull file-like object

2016-12-04 Thread Martin Panter
Martin Panter added the comment: If you only need the readable interface, use BytesIO or StringIO. I once had an implementation like Serhiy’s, called dummywriter: . To fully implement the writable file API it should also

[issue28864] Add devnull file-like object

2016-12-04 Thread R. David Murray
R. David Murray added the comment: Yes, in my mind open(os.devnull) is the "obvious way" to do this. -- nosy: +r.david.murray ___ Python tracker ___

[issue28864] Add devnull file-like object

2016-12-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you need true file object, with name, fileno() etc, you can use open(os.devnull, 'w'). If the simple file-like object is enough, it is just few lines: class NullWriter: def write(self, s): pass io.StringIO() works in most cases well too.

[issue28864] Add devnull file-like object

2016-12-03 Thread Raymond Hettinger
New submission from Raymond Hettinger: Uses cases are the same as /dev/null: with redirect_stderr(io.DevNull()): some_func_using_stdout_and_stderr() -- messages: 282314 nosy: ncoghlan, pitrou, rhettinger priority: low severity: normal status: open title: Add devnull file-like