Skip to content
This repository
Browse code

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...
commit 269780a7686aaa8a919aa187a0d38d31125a5a51 1 parent 360536a
Johannes Dewender authored March 15, 2012

Showing 1 changed file with 1 addition and 25 deletions. Show diff stats Hide diff stats

  1. 26  src/epydoc/docintrospecter.py
26  src/epydoc/docintrospecter.py
@@ -915,6 +915,7 @@ def _import(name, filename=None):
915 915
 
916 916
     # Suppress input and output.  (These get restored when we restore
917 917
     # sys to old_sys).  
  918
+    _dev_null = open(os.devnull, "w")
918 919
     sys.stdin = sys.stdout = sys.stderr = _dev_null
919 920
     sys.__stdin__ = sys.__stdout__ = sys.__stderr__ = _dev_null
920 921
 
@@ -970,31 +971,6 @@ def introspect_docstring_lineno(api_doc):
970 971
                         % api_doc.canonical_name)
971 972
     return None
972 973
 
973  
-class _DevNull:
974  
-    """
975  
-    A "file-like" object that discards anything that is written and
976  
-    always reports end-of-file when read.  C{_DevNull} is used by
977  
-    L{_import()} to discard output when importing modules; and to
978  
-    ensure that stdin appears closed.
979  
-    """
980  
-    def __init__(self):
981  
-        self.closed = 1
982  
-        self.mode = 'r+'
983  
-        self.softspace = 0
984  
-        self.name='</dev/null>'
985  
-    def close(self): pass
986  
-    def flush(self): pass
987  
-    def read(self, size=0): return ''
988  
-    def readline(self, size=0): return ''
989  
-    def readlines(self, sizehint=0): return []
990  
-    def seek(self, offset, whence=0): pass
991  
-    def tell(self): return 0L
992  
-    def truncate(self, size=0): pass
993  
-    def write(self, str): pass
994  
-    def writelines(self, sequence): pass
995  
-    xreadlines = readlines
996  
-_dev_null = _DevNull()
997  
-    
998 974
 ######################################################################
999 975
 ## Zope InterfaceClass
1000 976
 ######################################################################

0 notes on commit 269780a

Please sign in to comment.
Something went wrong with that request. Please try again.