Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f015784d
Commit
f015784d
authored
Jun 08, 2004
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature request #935915: Add os.path.devnull.
parent
046431b8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
6 deletions
+31
-6
Doc/lib/libos.tex
Doc/lib/libos.tex
+8
-0
Lib/macpath.py
Lib/macpath.py
+2
-1
Lib/ntpath.py
Lib/ntpath.py
+2
-1
Lib/os.py
Lib/os.py
+4
-2
Lib/os2emxpath.py
Lib/os2emxpath.py
+2
-1
Lib/posixpath.py
Lib/posixpath.py
+2
-1
Lib/test/test_os.py
Lib/test/test_os.py
+9
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libos.tex
View file @
f015784d
...
@@ -1808,3 +1808,11 @@ current platform. This may be a single character, such as \code{'\e
...
@@ -1808,3 +1808,11 @@ current platform. This may be a single character, such as \code{'\e
n'
}
for
\POSIX
{}
or
\code
{
'
\e
r'
}
for Mac OS, or multiple characters,
n'
}
for
\POSIX
{}
or
\code
{
'
\e
r'
}
for Mac OS, or multiple characters,
for example,
\code
{
'
\e
r
\e
n'
}
for Windows.
for example,
\code
{
'
\e
r
\e
n'
}
for Windows.
\end{datadesc}
\end{datadesc}
\begin{datadesc}
{
devnull
}
The file path of the null device.
For example:
\code
{
'/dev/null'
}
for
\POSIX
{}
or
\code
{
'Dev:Nul'
}
for the
Macintosh.
Also available via
\module
{
os.path
}
.
\versionadded
{
2.4
}
\end{datadesc}
Lib/macpath.py
View file @
f015784d
...
@@ -8,7 +8,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
...
@@ -8,7 +8,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"getatime"
,
"getctime"
,
"islink"
,
"exists"
,
"isdir"
,
"isfile"
,
"getatime"
,
"getctime"
,
"islink"
,
"exists"
,
"isdir"
,
"isfile"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"realpath"
,
"supports_unicode_filenames"
]
"
devnull"
,
"
realpath"
,
"supports_unicode_filenames"
]
# strings representing various path-related bits and pieces
# strings representing various path-related bits and pieces
curdir
=
':'
curdir
=
':'
...
@@ -18,6 +18,7 @@ sep = ':'
...
@@ -18,6 +18,7 @@ sep = ':'
pathsep
=
'
\
n
'
pathsep
=
'
\
n
'
defpath
=
':'
defpath
=
':'
altsep
=
None
altsep
=
None
devnull
=
'Dev:Null'
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
...
...
Lib/ntpath.py
View file @
f015784d
...
@@ -14,7 +14,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
...
@@ -14,7 +14,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"getatime"
,
"getctime"
,
"islink"
,
"exists"
,
"isdir"
,
"isfile"
,
"ismount"
,
"getatime"
,
"getctime"
,
"islink"
,
"exists"
,
"isdir"
,
"isfile"
,
"ismount"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"splitunc"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"splitunc"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"realpath"
,
"supports_unicode_filenames"
]
"
devnull"
,
"
realpath"
,
"supports_unicode_filenames"
]
# strings representing various path-related bits and pieces
# strings representing various path-related bits and pieces
curdir
=
'.'
curdir
=
'.'
...
@@ -29,6 +29,7 @@ if 'ce' in sys.builtin_module_names:
...
@@ -29,6 +29,7 @@ if 'ce' in sys.builtin_module_names:
elif
'os2'
in
sys
.
builtin_module_names
:
elif
'os2'
in
sys
.
builtin_module_names
:
# OS/2 w/ VACPP
# OS/2 w/ VACPP
altsep
=
'/'
altsep
=
'/'
devnull
=
'nul'
# Normalize the case of a pathname and map slashes to backslashes.
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
# Other normalizations (such as optimizing '../' away) are not done
...
...
Lib/os.py
View file @
f015784d
...
@@ -12,6 +12,7 @@ This exports:
...
@@ -12,6 +12,7 @@ This exports:
- os.pathsep is the component separator used in $PATH etc
- os.pathsep is the component separator used in $PATH etc
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
- os.defpath is the default search path for executables
- os.defpath is the default search path for executables
- os.devnull is the file path of the null device ('/dev/null', etc.)
Programs that import and use 'os' stand a better chance of being
Programs that import and use 'os' stand a better chance of being
portable between different platforms. Of course, they must then
portable between different platforms. Of course, they must then
...
@@ -28,7 +29,7 @@ _names = sys.builtin_module_names
...
@@ -28,7 +29,7 @@ _names = sys.builtin_module_names
# Note: more names are added to __all__ later.
# Note: more names are added to __all__ later.
__all__
=
[
"altsep"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"linesep"
,
__all__
=
[
"altsep"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"linesep"
,
"defpath"
,
"name"
,
"path"
]
"defpath"
,
"name"
,
"path"
,
"devnull"
]
def
_get_exports_list
(
module
):
def
_get_exports_list
(
module
):
try
:
try
:
...
@@ -129,7 +130,8 @@ else:
...
@@ -129,7 +130,8 @@ else:
raise
ImportError
,
'no os specific module found'
raise
ImportError
,
'no os specific module found'
sys
.
modules
[
'os.path'
]
=
path
sys
.
modules
[
'os.path'
]
=
path
from
os.path
import
curdir
,
pardir
,
sep
,
pathsep
,
defpath
,
extsep
,
altsep
from
os.path
import
curdir
,
pardir
,
sep
,
pathsep
,
defpath
,
extsep
,
altsep
,
\
devnull
del
_names
del
_names
...
...
Lib/os2emxpath.py
View file @
f015784d
...
@@ -13,7 +13,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
...
@@ -13,7 +13,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"getatime"
,
"getctime"
,
"islink"
,
"exists"
,
"isdir"
,
"isfile"
,
"ismount"
,
"getatime"
,
"getctime"
,
"islink"
,
"exists"
,
"isdir"
,
"isfile"
,
"ismount"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"splitunc"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"splitunc"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"realpath"
,
"supports_unicode_filenames"
]
"
devnull"
,
"
realpath"
,
"supports_unicode_filenames"
]
# strings representing various path-related bits and pieces
# strings representing various path-related bits and pieces
curdir
=
'.'
curdir
=
'.'
...
@@ -23,6 +23,7 @@ sep = '/'
...
@@ -23,6 +23,7 @@ sep = '/'
altsep
=
'
\
\
'
altsep
=
'
\
\
'
pathsep
=
';'
pathsep
=
';'
defpath
=
'.;C:
\
\
bin'
defpath
=
'.;C:
\
\
bin'
devnull
=
'nul'
# Normalize the case of a pathname and map slashes to backslashes.
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
# Other normalizations (such as optimizing '../' away) are not done
...
...
Lib/posixpath.py
View file @
f015784d
...
@@ -19,7 +19,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
...
@@ -19,7 +19,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"walk"
,
"expanduser"
,
"expandvars"
,
"normpath"
,
"abspath"
,
"samefile"
,
"sameopenfile"
,
"samestat"
,
"samefile"
,
"sameopenfile"
,
"samestat"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"curdir"
,
"pardir"
,
"sep"
,
"pathsep"
,
"defpath"
,
"altsep"
,
"extsep"
,
"realpath"
,
"supports_unicode_filenames"
]
"
devnull"
,
"
realpath"
,
"supports_unicode_filenames"
]
# strings representing various path-related bits and pieces
# strings representing various path-related bits and pieces
curdir
=
'.'
curdir
=
'.'
...
@@ -29,6 +29,7 @@ sep = '/'
...
@@ -29,6 +29,7 @@ sep = '/'
pathsep
=
':'
pathsep
=
':'
defpath
=
':/bin:/usr/bin'
defpath
=
':/bin:/usr/bin'
altsep
=
None
altsep
=
None
devnull
=
'/dev/null'
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
# On MS-DOS this may also turn slashes into backslashes; however, other
...
...
Lib/test/test_os.py
View file @
f015784d
...
@@ -334,6 +334,14 @@ class MakedirTests (unittest.TestCase):
...
@@ -334,6 +334,14 @@ class MakedirTests (unittest.TestCase):
os
.
removedirs
(
path
)
os
.
removedirs
(
path
)
class
DevNullTests
(
unittest
.
TestCase
):
def
test_devnull
(
self
):
f
=
file
(
os
.
devnull
,
'w'
)
f
.
write
(
'hello'
)
f
.
close
()
f
=
file
(
os
.
devnull
,
'r'
)
assert
f
.
read
()
==
''
f
.
close
()
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
test_support
.
run_unittest
(
...
@@ -342,6 +350,7 @@ def test_main():
...
@@ -342,6 +350,7 @@ def test_main():
EnvironTests
,
EnvironTests
,
WalkTests
,
WalkTests
,
MakedirTests
,
MakedirTests
,
DevNullTests
,
)
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
Misc/NEWS
View file @
f015784d
...
@@ -328,6 +328,8 @@ Extension modules
...
@@ -328,6 +328,8 @@ Extension modules
Library
Library
-------
-------
-
os
.
path
.
devnull
has
been
added
for
all
supported
platforms
.
-
Fixed
#
877165
:
distutils
now
picks
the
right
C
++
compiler
command
-
Fixed
#
877165
:
distutils
now
picks
the
right
C
++
compiler
command
on
cygwin
and
mingw32
.
on
cygwin
and
mingw32
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment