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
1e62bf14
Kaydet (Commit)
1e62bf14
authored
Nis 19, 2017
tarafından
Victor Stinner
Kaydeden (comit)
GitHub
Nis 19, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30030: Revert
f50354ad
(tempfile) (#1187)
Revert
f50354ad
: it introduced a regression in test_threadedtempfile.
üst
66bffd16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
tempfile.py
Lib/tempfile.py
+23
-12
test_tempfile.py
Lib/test/test_tempfile.py
+2
-3
No files found.
Lib/tempfile.py
Dosyayı görüntüle @
1e62bf14
...
@@ -133,21 +133,32 @@ def _sanitize_params(prefix, suffix, dir):
...
@@ -133,21 +133,32 @@ def _sanitize_params(prefix, suffix, dir):
return
prefix
,
suffix
,
dir
,
output_type
return
prefix
,
suffix
,
dir
,
output_type
def
_RandomNameSequence
():
class
_RandomNameSequence
:
"""Generate an endless sequence of unpredictable strings which
"""An instance of _RandomNameSequence generates an endless
can safely be incorporated into file names. Each string is 8
sequence of unpredictable strings which can safely be incorporated
characters long. Multiple threads and forked processes can
into file names. Each string is six characters long. Multiple
safely use the same instance at the same time."""
threads can safely use the same instance at the same time.
_RandomNameSequence is an iterator."""
characters
=
"abcdefghijklmnopqrstuvwxyz0123456789_"
characters
=
"abcdefghijklmnopqrstuvwxyz0123456789_"
rng_pid
=
None
while
True
:
@property
def
rng
(
self
):
cur_pid
=
_os
.
getpid
()
cur_pid
=
_os
.
getpid
()
if
cur_pid
!=
rng_pid
:
if
cur_pid
!=
getattr
(
self
,
'_rng_pid'
,
None
):
choose
=
_Random
()
.
choice
self
.
_rng
=
_Random
()
rng_pid
=
cur_pid
self
.
_rng_pid
=
cur_pid
letters
=
[
choose
(
characters
)
for
dummy
in
range
(
8
)]
return
self
.
_rng
yield
''
.
join
(
letters
)
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
c
=
self
.
characters
choose
=
self
.
rng
.
choice
letters
=
[
choose
(
c
)
for
dummy
in
range
(
8
)]
return
''
.
join
(
letters
)
def
_candidate_tempdir_list
():
def
_candidate_tempdir_list
():
"""Generate a list of candidate temporary directories which
"""Generate a list of candidate temporary directories which
...
...
Lib/test/test_tempfile.py
Dosyayı görüntüle @
1e62bf14
# tempfile.py unit tests.
# tempfile.py unit tests.
import
collections.abc
import
tempfile
import
tempfile
import
errno
import
errno
import
io
import
io
...
@@ -291,9 +290,9 @@ class TestGetCandidateNames(BaseTestCase):
...
@@ -291,9 +290,9 @@ class TestGetCandidateNames(BaseTestCase):
"""Test the internal function _get_candidate_names."""
"""Test the internal function _get_candidate_names."""
def
test_retval
(
self
):
def
test_retval
(
self
):
# _get_candidate_names returns a
n iterator
# _get_candidate_names returns a
_RandomNameSequence object
obj
=
tempfile
.
_get_candidate_names
()
obj
=
tempfile
.
_get_candidate_names
()
self
.
assertIsInstance
(
obj
,
collections
.
abc
.
Iterator
)
self
.
assertIsInstance
(
obj
,
tempfile
.
_RandomNameSequence
)
def
test_same_thing
(
self
):
def
test_same_thing
(
self
):
# _get_candidate_names always returns the same object
# _get_candidate_names always returns the same object
...
...
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