]> granicus.if.org Git - python/commitdiff
Use os.devnull instead of hardcoded '/dev/null'.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 15 Feb 2015 11:57:49 +0000 (13:57 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 15 Feb 2015 11:57:49 +0000 (13:57 +0200)
Lib/test/test_cgi.py
Lib/test/test_sysconfig.py
Tools/compiler/compile.py

index c9cf09525d713a534afc0457cfcf2a4d56e94a00..04a1e48afd899d2dd109d21b96b8fd3578840a15 100644 (file)
@@ -194,9 +194,9 @@ class CgiTests(unittest.TestCase):
         cgi.initlog("%s", "Testing initlog 1")
         cgi.log("%s", "Testing log 2")
         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.logfile = "/dev/null"
+            cgi.logfile = os.devnull
             cgi.initlog("%s", "Testing log 3")
             cgi.log("Testing log 4")
 
index a0b65dfc10b910b09171cc0b60b22dca81275386..18a85fd253cbcf887a56aae9ccb3fb1f9d02daec 100644 (file)
@@ -294,7 +294,7 @@ class TestSysConfig(unittest.TestCase):
         if 'MACOSX_DEPLOYMENT_TARGET' in env:
             del env['MACOSX_DEPLOYMENT_TARGET']
 
-        with open('/dev/null', 'w') as devnull_fp:
+        with open(os.devnull, 'w') as devnull_fp:
             p = subprocess.Popen([
                     sys.executable, '-c',
                    'import sysconfig; print(sysconfig.get_platform())',
@@ -320,7 +320,7 @@ class TestSysConfig(unittest.TestCase):
                 'import sysconfig; print(sysconfig.get_platform())',
             ],
             stdout=subprocess.PIPE,
-            stderr=open('/dev/null'),
+            stderr=open(os.devnull),
             env=env)
         test_platform = p.communicate()[0].strip()
         test_platform = test_platform.decode('utf-8')
index 9d50425d38d9a56bd78e7203b94780deec8c48b5..9e5c80123f4224d5b3e7136d6764e9c1c296ac20 100644 (file)
@@ -1,3 +1,4 @@
+import os
 import sys
 import getopt
 
@@ -16,11 +17,7 @@ def main():
             VERBOSE = 1
             visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1
         if k == '-q':
-            if sys.platform[:3]=="win":
-                f = open('nul', 'wb') # /dev/null fails on Windows...
-            else:
-                f = open('/dev/null', 'wb')
-            sys.stdout = f
+            sys.stdout = open(os.devnull, 'wb')
         if k == '-d':
             DISPLAY = 1
         if k == '-c':