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
8ab440e4
Commit
8ab440e4
authored
Nov 15, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
8ad982cc
1ab6c2d2
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
262 additions
and
167 deletions
+262
-167
Doc/whatsnew/3.3.rst
Doc/whatsnew/3.3.rst
+4
-0
Lib/test/test_genericpath.py
Lib/test/test_genericpath.py
+14
-7
Lib/test/test_ntpath.py
Lib/test/test_ntpath.py
+5
-2
Lib/test/test_os.py
Lib/test/test_os.py
+40
-4
Lib/test/test_pep277.py
Lib/test/test_pep277.py
+7
-2
Lib/test/test_posixpath.py
Lib/test/test_posixpath.py
+7
-5
Misc/NEWS
Misc/NEWS
+4
-0
Modules/posixmodule.c
Modules/posixmodule.c
+181
-147
No files found.
Doc/whatsnew/3.3.rst
View file @
8ab440e4
...
...
@@ -573,6 +573,10 @@ Porting Python code
with sys.platform.startswith('linux'), or directly sys.platform == 'linux' if
you don't need to support older Python versions.
* Issue #13374: The Windows bytes API has been deprecated in the :mod:`os`
module. Use Unicode filenames instead of bytes filenames to not depend on the
ANSI code page anymore and to support any filename.
Porting C code
--------------
...
...
Lib/test/test_genericpath.py
View file @
8ab440e4
...
...
@@ -2,11 +2,12 @@
Tests common to genericpath, macpath, ntpath and posixpath
"""
import
unittest
from
test
import
support
import
os
import
genericpath
import
os
import
sys
import
unittest
import
warnings
from
test
import
support
def
safe_rmdir
(
dirname
):
...
...
@@ -258,6 +259,8 @@ class CommonTest(GenericTest):
def
test_abspath
(
self
):
self
.
assertIn
(
"foo"
,
self
.
pathmodule
.
abspath
(
"foo"
))
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
assertIn
(
b"foo"
,
self
.
pathmodule
.
abspath
(
b"foo"
))
# Abspath returns bytes when the arg is bytes
...
...
@@ -266,6 +269,8 @@ class CommonTest(GenericTest):
def
test_realpath
(
self
):
self
.
assertIn
(
"foo"
,
self
.
pathmodule
.
realpath
(
"foo"
))
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
assertIn
(
b"foo"
,
self
.
pathmodule
.
realpath
(
b"foo"
))
def
test_normpath_issue5827
(
self
):
...
...
@@ -296,6 +301,8 @@ class CommonTest(GenericTest):
"Mac OS X denies the creation of a directory with an invalid utf8 name"
)
def
test_nonascii_abspath
(
self
):
# Test non-ASCII, non-UTF8 bytes in the path.
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
with
support
.
temp_cwd
(
b'
\
xe7
w
\
xf0
'
):
self
.
test_abspath
()
...
...
Lib/test/test_ntpath.py
View file @
8ab440e4
import
ntpath
import
os
import
sys
import
unittest
import
warnings
from
test.support
import
TestFailed
from
test
import
support
,
test_genericpath
from
tempfile
import
TemporaryFile
import
unittest
def
tester
(
fn
,
wantResult
):
...
...
@@ -21,6 +22,8 @@ def tester(fn, wantResult):
fn
=
fn
.
replace
(
'["'
,
'[b"'
)
fn
=
fn
.
replace
(
", '"
,
", b'"
)
fn
=
fn
.
replace
(
', "'
,
', b"'
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
gotResult
=
eval
(
fn
)
if
isinstance
(
wantResult
,
str
):
wantResult
=
wantResult
.
encode
(
'ascii'
)
...
...
Lib/test/test_os.py
View file @
8ab440e4
...
...
@@ -213,6 +213,8 @@ class StatAttributeTests(unittest.TestCase):
fname
=
self
.
fname
.
encode
(
sys
.
getfilesystemencoding
())
except
UnicodeEncodeError
:
self
.
skipTest
(
"cannot encode %a for the filesystem"
%
self
.
fname
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
check_stat_attributes
(
fname
)
def
test_statvfs_attributes
(
self
):
...
...
@@ -838,6 +840,8 @@ class LinkTests(unittest.TestCase):
with
open
(
file1
,
"w"
)
as
f1
:
f1
.
write
(
"test"
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
os
.
link
(
file1
,
file2
)
with
open
(
file1
,
"r"
)
as
f1
,
open
(
file2
,
"r"
)
as
f2
:
self
.
assertTrue
(
os
.
path
.
sameopenfile
(
f1
.
fileno
(),
f2
.
fileno
()))
...
...
@@ -1160,6 +1164,8 @@ class Win32SymlinkTests(unittest.TestCase):
self
.
assertNotEqual
(
os
.
lstat
(
link
),
os
.
stat
(
link
))
bytes_link
=
os
.
fsencode
(
link
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
assertEqual
(
os
.
stat
(
bytes_link
),
os
.
stat
(
target
))
self
.
assertNotEqual
(
os
.
lstat
(
bytes_link
),
os
.
stat
(
bytes_link
))
...
...
@@ -1619,6 +1625,35 @@ class ExtendedAttributeTests(unittest.TestCase):
self
.
_check_xattrs
(
getxattr
,
setxattr
,
removexattr
,
listxattr
)
@
unittest
.
skipUnless
(
sys
.
platform
==
"win32"
,
"Win32 specific tests"
)
class
Win32DeprecatedBytesAPI
(
unittest
.
TestCase
):
def
test_deprecated
(
self
):
import
nt
filename
=
os
.
fsencode
(
support
.
TESTFN
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"error"
,
DeprecationWarning
)
for
func
,
*
args
in
(
(
nt
.
_getfullpathname
,
filename
),
(
nt
.
_isdir
,
filename
),
(
os
.
access
,
filename
,
os
.
R_OK
),
(
os
.
chdir
,
filename
),
(
os
.
chmod
,
filename
,
0o777
),
(
os
.
link
,
filename
,
filename
),
(
os
.
listdir
,
filename
),
(
os
.
lstat
,
filename
),
(
os
.
mkdir
,
filename
),
(
os
.
open
,
filename
,
os
.
O_RDONLY
),
(
os
.
rename
,
filename
,
filename
),
(
os
.
rmdir
,
filename
),
(
os
.
startfile
,
filename
),
(
os
.
stat
,
filename
),
(
os
.
symlink
,
filename
,
filename
),
(
os
.
unlink
,
filename
),
(
os
.
utime
,
filename
),
):
self
.
assertRaises
(
DeprecationWarning
,
func
,
*
args
)
@
support
.
reap_threads
def
test_main
():
support
.
run_unittest
(
...
...
@@ -1643,6 +1678,7 @@ def test_main():
TestSendfile
,
ProgramPriorityTests
,
ExtendedAttributeTests
,
Win32DeprecatedBytesAPI
,
)
if
__name__
==
"__main__"
:
...
...
Lib/test/test_pep277.py
View file @
8ab440e4
# Test the Unicode versions of normal file functions
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
import
sys
,
os
,
unittest
import
os
import
sys
import
unittest
import
warnings
from
unicodedata
import
normalize
from
test
import
support
...
...
@@ -155,6 +158,8 @@ class UnicodeFileTests(unittest.TestCase):
@
unittest
.
skipIf
(
sys
.
platform
==
'darwin'
,
'irrelevant test on Mac OS X'
)
def
test_listdir
(
self
):
sf0
=
set
(
self
.
files
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
f1
=
os
.
listdir
(
support
.
TESTFN
.
encode
(
sys
.
getfilesystemencoding
()))
f2
=
os
.
listdir
(
support
.
TESTFN
)
sf2
=
set
(
os
.
path
.
join
(
support
.
TESTFN
,
f
)
for
f
in
f2
)
...
...
Lib/test/test_posixpath.py
View file @
8ab440e4
import
unittest
from
test
import
support
,
test_genericpath
import
posixpath
import
os
import
posixpath
import
sys
import
unittest
import
warnings
from
posixpath
import
realpath
,
abspath
,
dirname
,
basename
from
test
import
support
,
test_genericpath
try
:
import
posix
...
...
@@ -231,6 +231,8 @@ class PosixPathTest(unittest.TestCase):
def
test_ismount
(
self
):
self
.
assertIs
(
posixpath
.
ismount
(
"/"
),
True
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
,
DeprecationWarning
)
self
.
assertIs
(
posixpath
.
ismount
(
b"/"
),
True
)
def
test_ismount_non_existent
(
self
):
...
...
Misc/NEWS
View file @
8ab440e4
...
...
@@ -374,6 +374,10 @@ Core and Builtins
Library
-------
-
Issue
#
13374
:
The
Windows
bytes
API
has
been
deprecated
in
the
os
module
.
Use
Unicode
filenames
instead
of
bytes
filenames
to
not
depend
on
the
ANSI
code
page
anymore
and
to
support
any
filename
.
-
Issue
#
13297
:
Use
bytes
type
to
send
and
receive
binary
data
through
XMLRPC
.
-
Issue
#
6397
:
Support
"/dev/poll"
polling
objects
in
select
module
,
...
...
Modules/posixmodule.c
View file @
8ab440e4
This diff is collapsed.
Click to expand it.
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