Permalink
Browse files

fix: _DevNull instance has no attribute 'isatty', sf 2682627

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...
1 parent 360536a commit 269780a7686aaa8a919aa187a0d38d31125a5a51 @JonnyJD committed Mar 14, 2012
Showing with 1 addition and 25 deletions.
  1. +1 −25 src/epydoc/docintrospecter.py
View
26 src/epydoc/docintrospecter.py
@@ -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
@@ -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
######################################################################

0 comments on commit 269780a

Please sign in to comment.