Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
bc89897e
Kaydet (Commit)
bc89897e
authored
Mar 06, 2008
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #2232: os.tmpfile might fail on Windows if the user has no
permission to create files in the root directory.
üst
2985e30b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
test_os.py
Lib/test/test_os.py
+38
-0
NEWS
Misc/NEWS
+7
-0
No files found.
Lib/test/test_os.py
Dosyayı görüntüle @
bc89897e
...
...
@@ -59,6 +59,44 @@ class TemporaryFileTests(unittest.TestCase):
def
test_tmpfile
(
self
):
if
not
hasattr
(
os
,
"tmpfile"
):
return
# As with test_tmpnam() below, the Windows implementation of tmpfile()
# attempts to create a file in the root directory of the current drive.
# On Vista and Server 2008, this test will always fail for normal users
# as writing to the root directory requires elevated privileges. With
# XP and below, the semantics of tmpfile() are the same, but the user
# running the test is more likely to have administrative privileges on
# their account already. If that's the case, then os.tmpfile() should
# work. In order to make this test as useful as possible, rather than
# trying to detect Windows versions or whether or not the user has the
# right permissions, just try and create a file in the root directory
# and see if it raises a 'Permission denied' OSError. If it does, then
# test that a subsequent call to os.tmpfile() raises the same error. If
# it doesn't, assume we're on XP or below and the user running the test
# has administrative privileges, and proceed with the test as normal.
if
sys
.
platform
==
'win32'
:
name
=
'
\\
python_test_os_test_tmpfile.txt'
if
os
.
path
.
exists
(
name
):
os
.
remove
(
name
)
try
:
fp
=
open
(
name
,
'w'
)
except
IOError
,
first
:
# open() failed, assert tmpfile() fails in the same way.
# Although open() raises an IOError and os.tmpfile() raises an
# OSError(), 'args' will be (13, 'Permission denied') in both
# cases.
try
:
fp
=
os
.
tmpfile
()
except
OSError
,
second
:
self
.
assertEqual
(
first
.
args
,
second
.
args
)
else
:
self
.
fail
(
"expected os.tmpfile() to raise OSError"
)
return
else
:
# open() worked, therefore, tmpfile() should work. Close our
# dummy file and proceed with the test as normal.
fp
.
close
()
os
.
remove
(
name
)
fp
=
os
.
tmpfile
()
fp
.
write
(
"foobar"
)
fp
.
seek
(
0
,
0
)
...
...
Misc/NEWS
Dosyayı görüntüle @
bc89897e
...
...
@@ -28,6 +28,13 @@ Library
Extension
Modules
-----------------
Tests
-----
-
Patch
#
2232
:
os
.
tmpfile
might
fail
on
Windows
if
the
user
has
no
permission
to
create
files
in
the
root
directory
.
Documentation
-------------
...
...
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