Skip to content

Commit

Permalink
fix: _DevNull instance has no attribute 'isatty', sf 2682627
Browse files Browse the repository at this point in the history
Fix for sourceforge id 2682627
"failure when parsing sys.stdin.isatty()"
https://sourceforge.net/support/tracker.php?aid=2682627

The error message generated was:

 Import failed (but source code parsing was successful).
     Error: AttributeError: _DevNull instance has no attribute 'isatty'

The special crafted object _DevNull is substituted with
open(os.devnull, "w")

Signed-off-by: Johannes Dewender <github@JonnyJD.net>
  • Loading branch information
JonnyJD committed Mar 14, 2012
1 parent 360536a commit 269780a
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions src/epydoc/docintrospecter.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ def _import(name, filename=None):

# Suppress input and output. (These get restored when we restore
# sys to old_sys).
_dev_null = open(os.devnull, "w")
sys.stdin = sys.stdout = sys.stderr = _dev_null
sys.__stdin__ = sys.__stdout__ = sys.__stderr__ = _dev_null

Expand Down Expand Up @@ -970,31 +971,6 @@ def introspect_docstring_lineno(api_doc):
% api_doc.canonical_name)
return None

class _DevNull:
"""
A "file-like" object that discards anything that is written and
always reports end-of-file when read. C{_DevNull} is used by
L{_import()} to discard output when importing modules; and to
ensure that stdin appears closed.
"""
def __init__(self):
self.closed = 1
self.mode = 'r+'
self.softspace = 0
self.name='</dev/null>'
def close(self): pass
def flush(self): pass
def read(self, size=0): return ''
def readline(self, size=0): return ''
def readlines(self, sizehint=0): return []
def seek(self, offset, whence=0): pass
def tell(self): return 0L
def truncate(self, size=0): pass
def write(self, str): pass
def writelines(self, sequence): pass
xreadlines = readlines
_dev_null = _DevNull()

######################################################################
## Zope InterfaceClass
######################################################################
Expand Down

0 comments on commit 269780a

Please sign in to comment.