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
0dc10e0d
Kaydet (Commit)
0dc10e0d
authored
Agu 29, 2014
tarafından
Berker Peksag
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #22182: Use e.args to unpack exceptions correctly in distutils.file_util.move_file.
Patch by Claudiu Popa.
üst
e6128a4a
6685883c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
file_util.py
Lib/distutils/file_util.py
+2
-2
test_file_util.py
Lib/distutils/tests/test_file_util.py
+20
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/distutils/file_util.py
Dosyayı görüntüle @
0dc10e0d
...
@@ -194,7 +194,7 @@ def move_file (src, dst,
...
@@ -194,7 +194,7 @@ def move_file (src, dst,
try
:
try
:
os
.
rename
(
src
,
dst
)
os
.
rename
(
src
,
dst
)
except
OSError
as
e
:
except
OSError
as
e
:
(
num
,
msg
)
=
e
(
num
,
msg
)
=
e
.
args
if
num
==
errno
.
EXDEV
:
if
num
==
errno
.
EXDEV
:
copy_it
=
True
copy_it
=
True
else
:
else
:
...
@@ -206,7 +206,7 @@ def move_file (src, dst,
...
@@ -206,7 +206,7 @@ def move_file (src, dst,
try
:
try
:
os
.
unlink
(
src
)
os
.
unlink
(
src
)
except
OSError
as
e
:
except
OSError
as
e
:
(
num
,
msg
)
=
e
(
num
,
msg
)
=
e
.
args
try
:
try
:
os
.
unlink
(
dst
)
os
.
unlink
(
dst
)
except
OSError
:
except
OSError
:
...
...
Lib/distutils/tests/test_file_util.py
Dosyayı görüntüle @
0dc10e0d
...
@@ -2,10 +2,13 @@
...
@@ -2,10 +2,13 @@
import
unittest
import
unittest
import
os
import
os
import
shutil
import
shutil
import
errno
from
unittest.mock
import
patch
from
distutils.file_util
import
move_file
from
distutils.file_util
import
move_file
from
distutils
import
log
from
distutils
import
log
from
distutils.tests
import
support
from
distutils.tests
import
support
from
distutils.errors
import
DistutilsFileError
from
test.support
import
run_unittest
from
test.support
import
run_unittest
class
FileUtilTestCase
(
support
.
TempdirManager
,
unittest
.
TestCase
):
class
FileUtilTestCase
(
support
.
TempdirManager
,
unittest
.
TestCase
):
...
@@ -58,6 +61,23 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -58,6 +61,23 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
wanted
=
[
'moving
%
s ->
%
s'
%
(
self
.
source
,
self
.
target_dir
)]
wanted
=
[
'moving
%
s ->
%
s'
%
(
self
.
source
,
self
.
target_dir
)]
self
.
assertEqual
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
@patch
(
'os.rename'
,
side_effect
=
OSError
(
'wrong'
,
1
))
def
test_move_file_exception_unpacking_rename
(
self
,
_
):
# see issue 22182
with
self
.
assertRaises
(
DistutilsFileError
):
with
open
(
self
.
source
,
'w'
)
as
fobj
:
fobj
.
write
(
'spam eggs'
)
move_file
(
self
.
source
,
self
.
target
,
verbose
=
0
)
@patch
(
'os.rename'
,
side_effect
=
OSError
(
errno
.
EXDEV
,
'wrong'
))
@patch
(
'os.unlink'
,
side_effect
=
OSError
(
'wrong'
,
1
))
def
test_move_file_exception_unpacking_unlink
(
self
,
rename
,
unlink
):
# see issue 22182
with
self
.
assertRaises
(
DistutilsFileError
):
with
open
(
self
.
source
,
'w'
)
as
fobj
:
fobj
.
write
(
'spam eggs'
)
move_file
(
self
.
source
,
self
.
target
,
verbose
=
0
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
FileUtilTestCase
)
return
unittest
.
makeSuite
(
FileUtilTestCase
)
...
...
Misc/NEWS
Dosyayı görüntüle @
0dc10e0d
...
@@ -124,6 +124,9 @@ Core and Builtins
...
@@ -124,6 +124,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
22182
:
Use
e
.
args
to
unpack
exceptions
correctly
in
distutils
.
file_util
.
move_file
.
Patch
by
Claudiu
Popa
.
-
The
webbrowser
module
now
uses
subprocess
's start_new_session=True rather
-
The
webbrowser
module
now
uses
subprocess
's start_new_session=True rather
than a potentially risky preexec_fn=os.setsid call.
than a potentially risky preexec_fn=os.setsid call.
...
...
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