Commit 8a1724bf authored by Serhiy Storchaka's avatar Serhiy Storchaka

Use os.devnull instead of hardcoded '/dev/null'.

parent a53bee51
...@@ -194,9 +194,9 @@ class CgiTests(unittest.TestCase): ...@@ -194,9 +194,9 @@ class CgiTests(unittest.TestCase):
cgi.initlog("%s", "Testing initlog 1") cgi.initlog("%s", "Testing initlog 1")
cgi.log("%s", "Testing log 2") cgi.log("%s", "Testing log 2")
self.assertEqual(cgi.logfp.getvalue(), "Testing initlog 1\nTesting log 2\n") self.assertEqual(cgi.logfp.getvalue(), "Testing initlog 1\nTesting log 2\n")
if os.path.exists("/dev/null"): if os.path.exists(os.devnull):
cgi.logfp = None cgi.logfp = None
cgi.logfile = "/dev/null" cgi.logfile = os.devnull
cgi.initlog("%s", "Testing log 3") cgi.initlog("%s", "Testing log 3")
cgi.log("Testing log 4") cgi.log("Testing log 4")
......
...@@ -294,7 +294,7 @@ class TestSysConfig(unittest.TestCase): ...@@ -294,7 +294,7 @@ class TestSysConfig(unittest.TestCase):
if 'MACOSX_DEPLOYMENT_TARGET' in env: if 'MACOSX_DEPLOYMENT_TARGET' in env:
del env['MACOSX_DEPLOYMENT_TARGET'] del env['MACOSX_DEPLOYMENT_TARGET']
with open('/dev/null', 'w') as devnull_fp: with open(os.devnull, 'w') as devnull_fp:
p = subprocess.Popen([ p = subprocess.Popen([
sys.executable, '-c', sys.executable, '-c',
'import sysconfig; print(sysconfig.get_platform())', 'import sysconfig; print(sysconfig.get_platform())',
...@@ -320,7 +320,7 @@ class TestSysConfig(unittest.TestCase): ...@@ -320,7 +320,7 @@ class TestSysConfig(unittest.TestCase):
'import sysconfig; print(sysconfig.get_platform())', 'import sysconfig; print(sysconfig.get_platform())',
], ],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=open('/dev/null'), stderr=open(os.devnull),
env=env) env=env)
test_platform = p.communicate()[0].strip() test_platform = p.communicate()[0].strip()
test_platform = test_platform.decode('utf-8') test_platform = test_platform.decode('utf-8')
......
import os
import sys import sys
import getopt import getopt
...@@ -16,11 +17,7 @@ def main(): ...@@ -16,11 +17,7 @@ def main():
VERBOSE = 1 VERBOSE = 1
visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1 visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1
if k == '-q': if k == '-q':
if sys.platform[:3]=="win": sys.stdout = open(os.devnull, 'wb')
f = open('nul', 'wb') # /dev/null fails on Windows...
else:
f = open('/dev/null', 'wb')
sys.stdout = f
if k == '-d': if k == '-d':
DISPLAY = 1 DISPLAY = 1
if k == '-c': if k == '-c':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment