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
cbc46afa
Kaydet (Commit)
cbc46afa
authored
Nis 14, 2017
tarafından
Mariatta
Kaydeden (comit)
GitHub
Nis 14, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[3.6] bpo-29694: race condition in pathlib mkdir with flags parents=True (GH-1089). (GH-1126)
(cherry picked from commit
22a594a0
)
üst
2cdf087d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
pathlib.py
Lib/pathlib.py
+2
-2
test_pathlib.py
Lib/test/test_pathlib.py
+30
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/pathlib.py
Dosyayı görüntüle @
cbc46afa
...
...
@@ -1230,8 +1230,8 @@ class Path(PurePath):
except
FileNotFoundError
:
if
not
parents
or
self
.
parent
==
self
:
raise
self
.
parent
.
mkdir
(
parents
=
True
)
self
.
_accessor
.
mkdir
(
self
,
mode
)
self
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
self
.
mkdir
(
mode
,
parents
=
False
,
exist_ok
=
exist_ok
)
except
OSError
:
# Cannot rely on checking for EEXIST, since the operating system
# could give priority to other errors like EACCES or EROFS
...
...
Lib/test/test_pathlib.py
Dosyayı görüntüle @
cbc46afa
...
...
@@ -8,6 +8,7 @@ import socket
import
stat
import
tempfile
import
unittest
from
unittest
import
mock
from
test
import
support
android_not_root
=
support
.
android_not_root
...
...
@@ -1816,6 +1817,35 @@ class _BasePathTest(object):
p
.
mkdir
(
exist_ok
=
True
)
self
.
assertEqual
(
cm
.
exception
.
errno
,
errno
.
EEXIST
)
def
test_mkdir_concurrent_parent_creation
(
self
):
for
pattern_num
in
range
(
32
):
p
=
self
.
cls
(
BASE
,
'dirCPC
%
d'
%
pattern_num
)
self
.
assertFalse
(
p
.
exists
())
def
my_mkdir
(
path
,
mode
=
0
o777
):
path
=
str
(
path
)
# Emulate another process that would create the directory
# just before we try to create it ourselves. We do it
# in all possible pattern combinations, assuming that this
# function is called at most 5 times (dirCPC/dir1/dir2,
# dirCPC/dir1, dirCPC, dirCPC/dir1, dirCPC/dir1/dir2).
if
pattern
.
pop
():
os
.
mkdir
(
path
,
mode
)
# from another process
concurrently_created
.
add
(
path
)
os
.
mkdir
(
path
,
mode
)
# our real call
pattern
=
[
bool
(
pattern_num
&
(
1
<<
n
))
for
n
in
range
(
5
)]
concurrently_created
=
set
()
p12
=
p
/
'dir1'
/
'dir2'
try
:
with
mock
.
patch
(
"pathlib._normal_accessor.mkdir"
,
my_mkdir
):
p12
.
mkdir
(
parents
=
True
,
exist_ok
=
False
)
except
FileExistsError
:
self
.
assertIn
(
str
(
p12
),
concurrently_created
)
else
:
self
.
assertNotIn
(
str
(
p12
),
concurrently_created
)
self
.
assertTrue
(
p
.
exists
())
@with_symlinks
def
test_symlink_to
(
self
):
P
=
self
.
cls
(
BASE
)
...
...
Misc/NEWS
Dosyayı görüntüle @
cbc46afa
...
...
@@ -31,6 +31,10 @@ Core and Builtins
Library
-------
- bpo-29694: Fixed race condition in pathlib mkdir with flags
parents=True. Patch by Armin Rigo.
- bpo-29692: Fixed arbitrary unchaining of RuntimeError exceptions in
contextlib.contextmanager.
Patch by Siddharth Velankar.
...
...
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