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
bee5cef7
Kaydet (Commit)
bee5cef7
authored
Kas 05, 2010
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Always close files in distutils code and tests (#10252).
üst
afb078dd
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
263 additions
and
173 deletions
+263
-173
ccompiler.py
Lib/distutils/ccompiler.py
+6
-4
bdist_wininst.py
Lib/distutils/command/bdist_wininst.py
+5
-1
upload.py
Lib/distutils/command/upload.py
+5
-1
core.py
Lib/distutils/core.py
+5
-1
cygwinccompiler.py
Lib/distutils/cygwinccompiler.py
+4
-1
dist.py
Lib/distutils/dist.py
+5
-3
emxccompiler.py
Lib/distutils/emxccompiler.py
+8
-4
extension.py
Lib/distutils/extension.py
+79
-76
file_util.py
Lib/distutils/file_util.py
+5
-3
test_build_py.py
Lib/distutils/tests/test_build_py.py
+8
-4
test_build_scripts.py
Lib/distutils/tests/test_build_scripts.py
+4
-2
test_config.py
Lib/distutils/tests/test_config.py
+6
-2
test_core.py
Lib/distutils/tests/test_core.py
+5
-1
test_dir_util.py
Lib/distutils/tests/test_dir_util.py
+4
-2
test_dist.py
Lib/distutils/tests/test_dist.py
+21
-19
test_file_util.py
Lib/distutils/tests/test_file_util.py
+4
-2
test_install.py
Lib/distutils/tests/test_install.py
+4
-1
test_msvc9compiler.py
Lib/distutils/tests/test_msvc9compiler.py
+9
-5
test_register.py
Lib/distutils/tests/test_register.py
+6
-2
test_sdist.py
Lib/distutils/tests/test_sdist.py
+6
-2
test_sysconfig.py
Lib/distutils/tests/test_sysconfig.py
+10
-6
test_text_file.py
Lib/distutils/tests/test_text_file.py
+35
-17
util.py
Lib/distutils/util.py
+9
-7
sysconfig.py
Lib/sysconfig.py
+10
-7
No files found.
Lib/distutils/ccompiler.py
Dosyayı görüntüle @
bee5cef7
...
@@ -779,14 +779,16 @@ class CCompiler:
...
@@ -779,14 +779,16 @@ class CCompiler:
library_dirs
=
[]
library_dirs
=
[]
fd
,
fname
=
tempfile
.
mkstemp
(
".c"
,
funcname
,
text
=
True
)
fd
,
fname
=
tempfile
.
mkstemp
(
".c"
,
funcname
,
text
=
True
)
f
=
os
.
fdopen
(
fd
,
"w"
)
f
=
os
.
fdopen
(
fd
,
"w"
)
for
incl
in
includes
:
try
:
f
.
write
(
"""#include "
%
s"
\n
"""
%
incl
)
for
incl
in
includes
:
f
.
write
(
"""
\
f
.
write
(
"""#include "
%
s"
\n
"""
%
incl
)
f
.
write
(
"""
\
main (int argc, char **argv) {
main (int argc, char **argv) {
%
s();
%
s();
}
}
"""
%
funcname
)
"""
%
funcname
)
f
.
close
()
finally
:
f
.
close
()
try
:
try
:
objects
=
self
.
compile
([
fname
],
include_dirs
=
include_dirs
)
objects
=
self
.
compile
([
fname
],
include_dirs
=
include_dirs
)
except
CompileError
:
except
CompileError
:
...
...
Lib/distutils/command/bdist_wininst.py
Dosyayı görüntüle @
bee5cef7
...
@@ -340,4 +340,8 @@ class bdist_wininst(Command):
...
@@ -340,4 +340,8 @@ class bdist_wininst(Command):
sfix
=
''
sfix
=
''
filename
=
os
.
path
.
join
(
directory
,
"wininst-
%.1
f
%
s.exe"
%
(
bv
,
sfix
))
filename
=
os
.
path
.
join
(
directory
,
"wininst-
%.1
f
%
s.exe"
%
(
bv
,
sfix
))
return
open
(
filename
,
"rb"
)
.
read
()
f
=
open
(
filename
,
"rb"
)
try
:
return
f
.
read
()
finally
:
f
.
close
()
Lib/distutils/command/upload.py
Dosyayı görüntüle @
bee5cef7
...
@@ -76,7 +76,11 @@ class upload(PyPIRCCommand):
...
@@ -76,7 +76,11 @@ class upload(PyPIRCCommand):
# Fill in the data - send all the meta-data in case we need to
# Fill in the data - send all the meta-data in case we need to
# register a new release
# register a new release
content
=
open
(
filename
,
'rb'
)
.
read
()
f
=
open
(
filename
,
'rb'
)
try
:
content
=
f
.
read
()
finally
:
f
.
close
()
meta
=
self
.
distribution
.
metadata
meta
=
self
.
distribution
.
metadata
data
=
{
data
=
{
# action
# action
...
...
Lib/distutils/core.py
Dosyayı görüntüle @
bee5cef7
...
@@ -215,7 +215,11 @@ def run_setup (script_name, script_args=None, stop_after="run"):
...
@@ -215,7 +215,11 @@ def run_setup (script_name, script_args=None, stop_after="run"):
sys
.
argv
[
0
]
=
script_name
sys
.
argv
[
0
]
=
script_name
if
script_args
is
not
None
:
if
script_args
is
not
None
:
sys
.
argv
[
1
:]
=
script_args
sys
.
argv
[
1
:]
=
script_args
exec
(
open
(
script_name
)
.
read
(),
g
,
l
)
f
=
open
(
script_name
)
try
:
exec
(
f
.
read
(),
g
,
l
)
finally
:
f
.
close
()
finally
:
finally
:
sys
.
argv
=
save_argv
sys
.
argv
=
save_argv
_setup_stop_after
=
None
_setup_stop_after
=
None
...
...
Lib/distutils/cygwinccompiler.py
Dosyayı görüntüle @
bee5cef7
...
@@ -350,11 +350,14 @@ def check_config_h():
...
@@ -350,11 +350,14 @@ def check_config_h():
# let's see if __GNUC__ is mentioned in python.h
# let's see if __GNUC__ is mentioned in python.h
fn
=
sysconfig
.
get_config_h_filename
()
fn
=
sysconfig
.
get_config_h_filename
()
try
:
try
:
with
open
(
fn
)
as
config_h
:
config_h
=
open
(
fn
)
try
:
if
"__GNUC__"
in
config_h
.
read
():
if
"__GNUC__"
in
config_h
.
read
():
return
CONFIG_H_OK
,
"'
%
s' mentions '__GNUC__'"
%
fn
return
CONFIG_H_OK
,
"'
%
s' mentions '__GNUC__'"
%
fn
else
:
else
:
return
CONFIG_H_NOTOK
,
"'
%
s' does not mention '__GNUC__'"
%
fn
return
CONFIG_H_NOTOK
,
"'
%
s' does not mention '__GNUC__'"
%
fn
finally
:
config_h
.
close
()
except
IOError
as
exc
:
except
IOError
as
exc
:
return
(
CONFIG_H_UNCERTAIN
,
return
(
CONFIG_H_UNCERTAIN
,
"couldn't read '
%
s':
%
s"
%
(
fn
,
exc
.
strerror
))
"couldn't read '
%
s':
%
s"
%
(
fn
,
exc
.
strerror
))
...
...
Lib/distutils/dist.py
Dosyayı görüntüle @
bee5cef7
...
@@ -1012,9 +1012,11 @@ class DistributionMetadata:
...
@@ -1012,9 +1012,11 @@ class DistributionMetadata:
def
write_pkg_info
(
self
,
base_dir
):
def
write_pkg_info
(
self
,
base_dir
):
"""Write the PKG-INFO file into the release tree.
"""Write the PKG-INFO file into the release tree.
"""
"""
pkg_info
=
open
(
os
.
path
.
join
(
base_dir
,
'PKG-INFO'
),
'w'
)
pkg_info
=
open
(
os
.
path
.
join
(
base_dir
,
'PKG-INFO'
),
'w'
)
self
.
write_pkg_file
(
pkg_info
)
try
:
pkg_info
.
close
()
self
.
write_pkg_file
(
pkg_info
)
finally
:
pkg_info
.
close
()
def
write_pkg_file
(
self
,
file
):
def
write_pkg_file
(
self
,
file
):
"""Write the PKG-INFO format data to a file object.
"""Write the PKG-INFO format data to a file object.
...
...
Lib/distutils/emxccompiler.py
Dosyayı görüntüle @
bee5cef7
...
@@ -270,8 +270,10 @@ def check_config_h():
...
@@ -270,8 +270,10 @@ def check_config_h():
# It would probably better to read single lines to search.
# It would probably better to read single lines to search.
# But we do this only once, and it is fast enough
# But we do this only once, and it is fast enough
f
=
open
(
fn
)
f
=
open
(
fn
)
s
=
f
.
read
()
try
:
f
.
close
()
s
=
f
.
read
()
finally
:
f
.
close
()
except
IOError
as
exc
:
except
IOError
as
exc
:
# if we can't read this file, we cannot say it is wrong
# if we can't read this file, we cannot say it is wrong
...
@@ -298,8 +300,10 @@ def get_versions():
...
@@ -298,8 +300,10 @@ def get_versions():
gcc_exe
=
find_executable
(
'gcc'
)
gcc_exe
=
find_executable
(
'gcc'
)
if
gcc_exe
:
if
gcc_exe
:
out
=
os
.
popen
(
gcc_exe
+
' -dumpversion'
,
'r'
)
out
=
os
.
popen
(
gcc_exe
+
' -dumpversion'
,
'r'
)
out_string
=
out
.
read
()
try
:
out
.
close
()
out_string
=
out
.
read
()
finally
:
out
.
close
()
result
=
re
.
search
(
'(
\
d+
\
.
\
d+
\
.
\
d+)'
,
out_string
,
re
.
ASCII
)
result
=
re
.
search
(
'(
\
d+
\
.
\
d+
\
.
\
d+)'
,
out_string
,
re
.
ASCII
)
if
result
:
if
result
:
gcc_version
=
StrictVersion
(
result
.
group
(
1
))
gcc_version
=
StrictVersion
(
result
.
group
(
1
))
...
...
Lib/distutils/extension.py
Dosyayı görüntüle @
bee5cef7
...
@@ -149,84 +149,87 @@ def read_setup_file(filename):
...
@@ -149,84 +149,87 @@ def read_setup_file(filename):
file
=
TextFile
(
filename
,
file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
1
,
join_lines
=
1
,
strip_comments
=
1
,
skip_blanks
=
1
,
join_lines
=
1
,
lstrip_ws
=
1
,
rstrip_ws
=
1
)
lstrip_ws
=
1
,
rstrip_ws
=
1
)
extensions
=
[]
try
:
extensions
=
[]
while
True
:
line
=
file
.
readline
()
while
True
:
if
line
is
None
:
# eof
line
=
file
.
readline
()
break
if
line
is
None
:
# eof
if
_variable_rx
.
match
(
line
):
# VAR=VALUE, handled in first pass
break
continue
if
_variable_rx
.
match
(
line
):
# VAR=VALUE, handled in first pass
if
line
[
0
]
==
line
[
-
1
]
==
"*"
:
file
.
warn
(
"'
%
s' lines not handled yet"
%
line
)
continue
line
=
expand_makefile_vars
(
line
,
vars
)
words
=
split_quoted
(
line
)
# NB. this parses a slightly different syntax than the old
# makesetup script: here, there must be exactly one extension per
# line, and it must be the first word of the line. I have no idea
# why the old syntax supported multiple extensions per line, as
# they all wind up being the same.
module
=
words
[
0
]
ext
=
Extension
(
module
,
[])
append_next_word
=
None
for
word
in
words
[
1
:]:
if
append_next_word
is
not
None
:
append_next_word
.
append
(
word
)
append_next_word
=
None
continue
continue
suffix
=
os
.
path
.
splitext
(
word
)[
1
]
if
line
[
0
]
==
line
[
-
1
]
==
"*"
:
switch
=
word
[
0
:
2
]
;
value
=
word
[
2
:]
file
.
warn
(
"'
%
s' lines not handled yet"
%
line
)
continue
if
suffix
in
(
".c"
,
".cc"
,
".cpp"
,
".cxx"
,
".c++"
,
".m"
,
".mm"
):
# hmm, should we do something about C vs. C++ sources?
line
=
expand_makefile_vars
(
line
,
vars
)
# or leave it up to the CCompiler implementation to
words
=
split_quoted
(
line
)
# worry about?
ext
.
sources
.
append
(
word
)
# NB. this parses a slightly different syntax than the old
elif
switch
==
"-I"
:
# makesetup script: here, there must be exactly one extension per
ext
.
include_dirs
.
append
(
value
)
# line, and it must be the first word of the line. I have no idea
elif
switch
==
"-D"
:
# why the old syntax supported multiple extensions per line, as
equals
=
value
.
find
(
"="
)
# they all wind up being the same.
if
equals
==
-
1
:
# bare "-DFOO" -- no value
ext
.
define_macros
.
append
((
value
,
None
))
module
=
words
[
0
]
else
:
# "-DFOO=blah"
ext
=
Extension
(
module
,
[])
ext
.
define_macros
.
append
((
value
[
0
:
equals
],
append_next_word
=
None
value
[
equals
+
2
:]))
elif
switch
==
"-U"
:
for
word
in
words
[
1
:]:
ext
.
undef_macros
.
append
(
value
)
if
append_next_word
is
not
None
:
elif
switch
==
"-C"
:
# only here 'cause makesetup has it!
append_next_word
.
append
(
word
)
ext
.
extra_compile_args
.
append
(
word
)
append_next_word
=
None
elif
switch
==
"-l"
:
continue
ext
.
libraries
.
append
(
value
)
elif
switch
==
"-L"
:
suffix
=
os
.
path
.
splitext
(
word
)[
1
]
ext
.
library_dirs
.
append
(
value
)
switch
=
word
[
0
:
2
]
;
value
=
word
[
2
:]
elif
switch
==
"-R"
:
ext
.
runtime_library_dirs
.
append
(
value
)
if
suffix
in
(
".c"
,
".cc"
,
".cpp"
,
".cxx"
,
".c++"
,
".m"
,
".mm"
):
elif
word
==
"-rpath"
:
# hmm, should we do something about C vs. C++ sources?
append_next_word
=
ext
.
runtime_library_dirs
# or leave it up to the CCompiler implementation to
elif
word
==
"-Xlinker"
:
# worry about?
append_next_word
=
ext
.
extra_link_args
ext
.
sources
.
append
(
word
)
elif
word
==
"-Xcompiler"
:
elif
switch
==
"-I"
:
append_next_word
=
ext
.
extra_compile_args
ext
.
include_dirs
.
append
(
value
)
elif
switch
==
"-u"
:
elif
switch
==
"-D"
:
ext
.
extra_link_args
.
append
(
word
)
equals
=
value
.
find
(
"="
)
if
not
value
:
if
equals
==
-
1
:
# bare "-DFOO" -- no value
ext
.
define_macros
.
append
((
value
,
None
))
else
:
# "-DFOO=blah"
ext
.
define_macros
.
append
((
value
[
0
:
equals
],
value
[
equals
+
2
:]))
elif
switch
==
"-U"
:
ext
.
undef_macros
.
append
(
value
)
elif
switch
==
"-C"
:
# only here 'cause makesetup has it!
ext
.
extra_compile_args
.
append
(
word
)
elif
switch
==
"-l"
:
ext
.
libraries
.
append
(
value
)
elif
switch
==
"-L"
:
ext
.
library_dirs
.
append
(
value
)
elif
switch
==
"-R"
:
ext
.
runtime_library_dirs
.
append
(
value
)
elif
word
==
"-rpath"
:
append_next_word
=
ext
.
runtime_library_dirs
elif
word
==
"-Xlinker"
:
append_next_word
=
ext
.
extra_link_args
append_next_word
=
ext
.
extra_link_args
elif
suffix
in
(
".a"
,
".so"
,
".sl"
,
".o"
,
".dylib"
):
elif
word
==
"-Xcompiler"
:
# NB. a really faithful emulation of makesetup would
append_next_word
=
ext
.
extra_compile_args
# append a .o file to extra_objects only if it
elif
switch
==
"-u"
:
# had a slash in it; otherwise, it would s/.o/.c/
ext
.
extra_link_args
.
append
(
word
)
# and append it to sources. Hmmmm.
if
not
value
:
ext
.
extra_objects
.
append
(
word
)
append_next_word
=
ext
.
extra_link_args
else
:
elif
suffix
in
(
".a"
,
".so"
,
".sl"
,
".o"
,
".dylib"
):
file
.
warn
(
"unrecognized argument '
%
s'"
%
word
)
# NB. a really faithful emulation of makesetup would
# append a .o file to extra_objects only if it
extensions
.
append
(
ext
)
# had a slash in it; otherwise, it would s/.o/.c/
# and append it to sources. Hmmmm.
ext
.
extra_objects
.
append
(
word
)
else
:
file
.
warn
(
"unrecognized argument '
%
s'"
%
word
)
extensions
.
append
(
ext
)
finally
:
file
.
close
()
return
extensions
return
extensions
Lib/distutils/file_util.py
Dosyayı görüntüle @
bee5cef7
...
@@ -234,6 +234,8 @@ def write_file (filename, contents):
...
@@ -234,6 +234,8 @@ def write_file (filename, contents):
sequence of strings without line terminators) to it.
sequence of strings without line terminators) to it.
"""
"""
f
=
open
(
filename
,
"w"
)
f
=
open
(
filename
,
"w"
)
for
line
in
contents
:
try
:
f
.
write
(
line
+
"
\n
"
)
for
line
in
contents
:
f
.
close
()
f
.
write
(
line
+
"
\n
"
)
finally
:
f
.
close
()
Lib/distutils/tests/test_build_py.py
Dosyayı görüntüle @
bee5cef7
...
@@ -19,11 +19,15 @@ class BuildPyTestCase(support.TempdirManager,
...
@@ -19,11 +19,15 @@ class BuildPyTestCase(support.TempdirManager,
def
test_package_data
(
self
):
def
test_package_data
(
self
):
sources
=
self
.
mkdtemp
()
sources
=
self
.
mkdtemp
()
f
=
open
(
os
.
path
.
join
(
sources
,
"__init__.py"
),
"w"
)
f
=
open
(
os
.
path
.
join
(
sources
,
"__init__.py"
),
"w"
)
f
.
write
(
"# Pretend this is a package."
)
try
:
f
.
close
()
f
.
write
(
"# Pretend this is a package."
)
finally
:
f
.
close
()
f
=
open
(
os
.
path
.
join
(
sources
,
"README.txt"
),
"w"
)
f
=
open
(
os
.
path
.
join
(
sources
,
"README.txt"
),
"w"
)
f
.
write
(
"Info about this package"
)
try
:
f
.
close
()
f
.
write
(
"Info about this package"
)
finally
:
f
.
close
()
destination
=
self
.
mkdtemp
()
destination
=
self
.
mkdtemp
()
...
...
Lib/distutils/tests/test_build_scripts.py
Dosyayı görüntüle @
bee5cef7
...
@@ -71,8 +71,10 @@ class BuildScriptsTestCase(support.TempdirManager,
...
@@ -71,8 +71,10 @@ class BuildScriptsTestCase(support.TempdirManager,
def
write_script
(
self
,
dir
,
name
,
text
):
def
write_script
(
self
,
dir
,
name
,
text
):
f
=
open
(
os
.
path
.
join
(
dir
,
name
),
"w"
)
f
=
open
(
os
.
path
.
join
(
dir
,
name
),
"w"
)
f
.
write
(
text
)
try
:
f
.
close
()
f
.
write
(
text
)
finally
:
f
.
close
()
def
test_version_int
(
self
):
def
test_version_int
(
self
):
source
=
self
.
mkdtemp
()
source
=
self
.
mkdtemp
()
...
...
Lib/distutils/tests/test_config.py
Dosyayı görüntüle @
bee5cef7
...
@@ -105,8 +105,12 @@ class PyPIRCCommandTestCase(support.TempdirManager,
...
@@ -105,8 +105,12 @@ class PyPIRCCommandTestCase(support.TempdirManager,
self
.
assertTrue
(
not
os
.
path
.
exists
(
rc
))
self
.
assertTrue
(
not
os
.
path
.
exists
(
rc
))
cmd
.
_store_pypirc
(
'tarek'
,
'xxx'
)
cmd
.
_store_pypirc
(
'tarek'
,
'xxx'
)
self
.
assertTrue
(
os
.
path
.
exists
(
rc
))
self
.
assertTrue
(
os
.
path
.
exists
(
rc
))
content
=
open
(
rc
)
.
read
()
f
=
open
(
rc
)
self
.
assertEquals
(
content
,
WANTED
)
try
:
content
=
f
.
read
()
self
.
assertEquals
(
content
,
WANTED
)
finally
:
f
.
close
()
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
PyPIRCCommandTestCase
)
return
unittest
.
makeSuite
(
PyPIRCCommandTestCase
)
...
...
Lib/distutils/tests/test_core.py
Dosyayı görüntüle @
bee5cef7
...
@@ -52,7 +52,11 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -52,7 +52,11 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
shutil
.
rmtree
(
path
)
shutil
.
rmtree
(
path
)
def
write_setup
(
self
,
text
,
path
=
test
.
support
.
TESTFN
):
def
write_setup
(
self
,
text
,
path
=
test
.
support
.
TESTFN
):
open
(
path
,
"w"
)
.
write
(
text
)
f
=
open
(
path
,
"w"
)
try
:
f
.
write
(
text
)
finally
:
f
.
close
()
return
path
return
path
def
test_run_setup_provides_file
(
self
):
def
test_run_setup_provides_file
(
self
):
...
...
Lib/distutils/tests/test_dir_util.py
Dosyayı görüntüle @
bee5cef7
...
@@ -88,8 +88,10 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -88,8 +88,10 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
mkpath
(
self
.
target
,
verbose
=
0
)
mkpath
(
self
.
target
,
verbose
=
0
)
a_file
=
os
.
path
.
join
(
self
.
target
,
'ok.txt'
)
a_file
=
os
.
path
.
join
(
self
.
target
,
'ok.txt'
)
f
=
open
(
a_file
,
'w'
)
f
=
open
(
a_file
,
'w'
)
f
.
write
(
'some content'
)
try
:
f
.
close
()
f
.
write
(
'some content'
)
finally
:
f
.
close
()
wanted
=
[
'copying
%
s ->
%
s'
%
(
a_file
,
self
.
target2
)]
wanted
=
[
'copying
%
s ->
%
s'
%
(
a_file
,
self
.
target2
)]
copy_tree
(
self
.
target
,
self
.
target2
,
verbose
=
1
)
copy_tree
(
self
.
target
,
self
.
target2
,
verbose
=
1
)
...
...
Lib/distutils/tests/test_dist.py
Dosyayı görüntüle @
bee5cef7
...
@@ -79,29 +79,29 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -79,29 +79,29 @@ class DistributionTestCase(support.LoggingSilencer,
def
test_command_packages_configfile
(
self
):
def
test_command_packages_configfile
(
self
):
sys
.
argv
.
append
(
"build"
)
sys
.
argv
.
append
(
"build"
)
self
.
addCleanup
(
os
.
unlink
,
TESTFN
)
f
=
open
(
TESTFN
,
"w"
)
f
=
open
(
TESTFN
,
"w"
)
try
:
try
:
print
(
"[global]"
,
file
=
f
)
print
(
"[global]"
,
file
=
f
)
print
(
"command_packages = foo.bar, splat"
,
file
=
f
)
print
(
"command_packages = foo.bar, splat"
,
file
=
f
)
finally
:
f
.
close
()
f
.
close
()
d
=
self
.
create_distribution
([
TESTFN
])
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
,
"foo.bar"
,
"splat"
])
# ensure command line overrides config:
sys
.
argv
[
1
:]
=
[
"--command-packages"
,
"spork"
,
"build"
]
d
=
self
.
create_distribution
([
TESTFN
])
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
,
"spork"
])
# Setting --command-packages to '' should cause the default to
# be used even if a config file specified something else:
sys
.
argv
[
1
:]
=
[
"--command-packages"
,
""
,
"build"
]
d
=
self
.
create_distribution
([
TESTFN
])
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
])
finally
:
d
=
self
.
create_distribution
([
TESTFN
])
os
.
unlink
(
TESTFN
)
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
,
"foo.bar"
,
"splat"
])
# ensure command line overrides config:
sys
.
argv
[
1
:]
=
[
"--command-packages"
,
"spork"
,
"build"
]
d
=
self
.
create_distribution
([
TESTFN
])
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
,
"spork"
])
# Setting --command-packages to '' should cause the default to
# be used even if a config file specified something else:
sys
.
argv
[
1
:]
=
[
"--command-packages"
,
""
,
"build"
]
d
=
self
.
create_distribution
([
TESTFN
])
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
])
def
test_empty_options
(
self
):
def
test_empty_options
(
self
):
# an empty options dictionary should not stay in the
# an empty options dictionary should not stay in the
...
@@ -260,8 +260,10 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -260,8 +260,10 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
temp_dir
=
self
.
mkdtemp
()
temp_dir
=
self
.
mkdtemp
()
user_filename
=
os
.
path
.
join
(
temp_dir
,
user_filename
)
user_filename
=
os
.
path
.
join
(
temp_dir
,
user_filename
)
f
=
open
(
user_filename
,
'w'
)
f
=
open
(
user_filename
,
'w'
)
f
.
write
(
'.'
)
try
:
f
.
close
()
f
.
write
(
'.'
)
finally
:
f
.
close
()
try
:
try
:
dist
=
Distribution
()
dist
=
Distribution
()
...
...
Lib/distutils/tests/test_file_util.py
Dosyayı görüntüle @
bee5cef7
...
@@ -31,8 +31,10 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -31,8 +31,10 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
def
test_move_file_verbosity
(
self
):
def
test_move_file_verbosity
(
self
):
f
=
open
(
self
.
source
,
'w'
)
f
=
open
(
self
.
source
,
'w'
)
f
.
write
(
'some content'
)
try
:
f
.
close
()
f
.
write
(
'some content'
)
finally
:
f
.
close
()
move_file
(
self
.
source
,
self
.
target
,
verbose
=
0
)
move_file
(
self
.
source
,
self
.
target
,
verbose
=
0
)
wanted
=
[]
wanted
=
[]
...
...
Lib/distutils/tests/test_install.py
Dosyayı görüntüle @
bee5cef7
...
@@ -182,8 +182,11 @@ class InstallTestCase(support.TempdirManager,
...
@@ -182,8 +182,11 @@ class InstallTestCase(support.TempdirManager,
# let's check the RECORD file was created with one
# let's check the RECORD file was created with one
# line (the egg info file)
# line (the egg info file)
with
open
(
cmd
.
record
)
as
f
:
f
=
open
(
cmd
.
record
)
try
:
self
.
assertEquals
(
len
(
f
.
readlines
()),
1
)
self
.
assertEquals
(
len
(
f
.
readlines
()),
1
)
finally
:
f
.
close
()
def
test_debug_mode
(
self
):
def
test_debug_mode
(
self
):
# this covers the code called when DEBUG is set
# this covers the code called when DEBUG is set
...
...
Lib/distutils/tests/test_msvc9compiler.py
Dosyayı görüntüle @
bee5cef7
...
@@ -113,17 +113,21 @@ class msvc9compilerTestCase(support.TempdirManager,
...
@@ -113,17 +113,21 @@ class msvc9compilerTestCase(support.TempdirManager,
tempdir
=
self
.
mkdtemp
()
tempdir
=
self
.
mkdtemp
()
manifest
=
os
.
path
.
join
(
tempdir
,
'manifest'
)
manifest
=
os
.
path
.
join
(
tempdir
,
'manifest'
)
f
=
open
(
manifest
,
'w'
)
f
=
open
(
manifest
,
'w'
)
f
.
write
(
_MANIFEST
)
try
:
f
.
close
()
f
.
write
(
_MANIFEST
)
finally
:
f
.
close
()
compiler
=
MSVCCompiler
()
compiler
=
MSVCCompiler
()
compiler
.
_remove_visual_c_ref
(
manifest
)
compiler
.
_remove_visual_c_ref
(
manifest
)
# see what we got
# see what we got
f
=
open
(
manifest
)
f
=
open
(
manifest
)
# removing trailing spaces
try
:
content
=
'
\n
'
.
join
([
line
.
rstrip
()
for
line
in
f
.
readlines
()])
# removing trailing spaces
f
.
close
()
content
=
'
\n
'
.
join
([
line
.
rstrip
()
for
line
in
f
.
readlines
()])
finally
:
f
.
close
()
# makes sure the manifest was properly cleaned
# makes sure the manifest was properly cleaned
self
.
assertEquals
(
content
,
_CLEANED_MANIFEST
)
self
.
assertEquals
(
content
,
_CLEANED_MANIFEST
)
...
...
Lib/distutils/tests/test_register.py
Dosyayı görüntüle @
bee5cef7
...
@@ -118,8 +118,12 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -118,8 +118,12 @@ class RegisterTestCase(PyPIRCCommandTestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
rc
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
rc
))
# with the content similar to WANTED_PYPIRC
# with the content similar to WANTED_PYPIRC
content
=
open
(
self
.
rc
)
.
read
()
f
=
open
(
self
.
rc
)
self
.
assertEquals
(
content
,
WANTED_PYPIRC
)
try
:
content
=
f
.
read
()
self
.
assertEquals
(
content
,
WANTED_PYPIRC
)
finally
:
f
.
close
()
# now let's make sure the .pypirc file generated
# now let's make sure the .pypirc file generated
# really works : we shouldn't be asked anything
# really works : we shouldn't be asked anything
...
...
Lib/distutils/tests/test_sdist.py
Dosyayı görüntüle @
bee5cef7
...
@@ -215,8 +215,12 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -215,8 +215,12 @@ class SDistTestCase(PyPIRCCommandTestCase):
self
.
assertEquals
(
len
(
content
),
11
)
self
.
assertEquals
(
len
(
content
),
11
)
# checking the MANIFEST
# checking the MANIFEST
manifest
=
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
.
read
()
f
=
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
self
.
assertEquals
(
manifest
,
MANIFEST
%
{
'sep'
:
os
.
sep
})
try
:
manifest
=
f
.
read
()
self
.
assertEquals
(
manifest
,
MANIFEST
%
{
'sep'
:
os
.
sep
})
finally
:
f
.
close
()
def
test_metadata_check_option
(
self
):
def
test_metadata_check_option
(
self
):
# testing the `medata-check` option
# testing the `medata-check` option
...
...
Lib/distutils/tests/test_sysconfig.py
Dosyayı görüntüle @
bee5cef7
...
@@ -75,9 +75,11 @@ class SysconfigTestCase(support.EnvironGuard,
...
@@ -75,9 +75,11 @@ class SysconfigTestCase(support.EnvironGuard,
def
test_parse_makefile_base
(
self
):
def
test_parse_makefile_base
(
self
):
self
.
makefile
=
TESTFN
self
.
makefile
=
TESTFN
fd
=
open
(
self
.
makefile
,
'w'
)
fd
=
open
(
self
.
makefile
,
'w'
)
fd
.
write
(
r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'"
'
\n
'
)
try
:
fd
.
write
(
'VAR=$OTHER
\n
OTHER=foo'
)
fd
.
write
(
r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'"
'
\n
'
)
fd
.
close
()
fd
.
write
(
'VAR=$OTHER
\n
OTHER=foo'
)
finally
:
fd
.
close
()
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
self
.
assertEquals
(
d
,
{
'CONFIG_ARGS'
:
"'--arg1=optarg1' 'ENV=LIB'"
,
self
.
assertEquals
(
d
,
{
'CONFIG_ARGS'
:
"'--arg1=optarg1' 'ENV=LIB'"
,
'OTHER'
:
'foo'
})
'OTHER'
:
'foo'
})
...
@@ -85,9 +87,11 @@ class SysconfigTestCase(support.EnvironGuard,
...
@@ -85,9 +87,11 @@ class SysconfigTestCase(support.EnvironGuard,
def
test_parse_makefile_literal_dollar
(
self
):
def
test_parse_makefile_literal_dollar
(
self
):
self
.
makefile
=
TESTFN
self
.
makefile
=
TESTFN
fd
=
open
(
self
.
makefile
,
'w'
)
fd
=
open
(
self
.
makefile
,
'w'
)
fd
.
write
(
r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'"
'
\n
'
)
try
:
fd
.
write
(
'VAR=$OTHER
\n
OTHER=foo'
)
fd
.
write
(
r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'"
'
\n
'
)
fd
.
close
()
fd
.
write
(
'VAR=$OTHER
\n
OTHER=foo'
)
finally
:
fd
.
close
()
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
self
.
assertEquals
(
d
,
{
'CONFIG_ARGS'
:
r"'--arg1=optarg1' 'ENV=\$LIB'"
,
self
.
assertEquals
(
d
,
{
'CONFIG_ARGS'
:
r"'--arg1=optarg1' 'ENV=\$LIB'"
,
'OTHER'
:
'foo'
})
'OTHER'
:
'foo'
})
...
...
Lib/distutils/tests/test_text_file.py
Dosyayı görüntüle @
bee5cef7
...
@@ -58,28 +58,46 @@ class TextFileTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -58,28 +58,46 @@ class TextFileTestCase(support.TempdirManager, unittest.TestCase):
finally
:
finally
:
out_file
.
close
()
out_file
.
close
()
in_file
=
TextFile
(
filename
,
strip_comments
=
0
,
skip_blanks
=
0
,
in_file
=
TextFile
(
filename
,
strip_comments
=
0
,
skip_blanks
=
0
,
lstrip_ws
=
0
,
rstrip_ws
=
0
)
lstrip_ws
=
0
,
rstrip_ws
=
0
)
test_input
(
1
,
"no processing"
,
in_file
,
result1
)
try
:
test_input
(
1
,
"no processing"
,
in_file
,
result1
)
finally
:
in_file
.
close
()
in_file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
0
,
in_file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
0
,
lstrip_ws
=
0
,
rstrip_ws
=
0
)
lstrip_ws
=
0
,
rstrip_ws
=
0
)
test_input
(
2
,
"strip comments"
,
in_file
,
result2
)
try
:
test_input
(
2
,
"strip comments"
,
in_file
,
result2
)
finally
:
in_file
.
close
()
in_file
=
TextFile
(
filename
,
strip_comments
=
0
,
skip_blanks
=
1
,
in_file
=
TextFile
(
filename
,
strip_comments
=
0
,
skip_blanks
=
1
,
lstrip_ws
=
0
,
rstrip_ws
=
0
)
lstrip_ws
=
0
,
rstrip_ws
=
0
)
test_input
(
3
,
"strip blanks"
,
in_file
,
result3
)
try
:
test_input
(
3
,
"strip blanks"
,
in_file
,
result3
)
finally
:
in_file
.
close
()
in_file
=
TextFile
(
filename
)
in_file
=
TextFile
(
filename
)
test_input
(
4
,
"default processing"
,
in_file
,
result4
)
try
:
test_input
(
4
,
"default processing"
,
in_file
,
result4
)
finally
:
in_file
.
close
()
in_file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
1
,
in_file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
1
,
join_lines
=
1
,
rstrip_ws
=
1
)
join_lines
=
1
,
rstrip_ws
=
1
)
test_input
(
5
,
"join lines without collapsing"
,
in_file
,
result5
)
try
:
test_input
(
5
,
"join lines without collapsing"
,
in_file
,
result5
)
finally
:
in_file
.
close
()
in_file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
1
,
in_file
=
TextFile
(
filename
,
strip_comments
=
1
,
skip_blanks
=
1
,
join_lines
=
1
,
rstrip_ws
=
1
,
collapse_join
=
1
)
join_lines
=
1
,
rstrip_ws
=
1
,
collapse_join
=
1
)
test_input
(
6
,
"join lines with collapsing"
,
in_file
,
result6
)
try
:
test_input
(
6
,
"join lines with collapsing"
,
in_file
,
result6
)
finally
:
in_file
.
close
()
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
TextFileTestCase
)
return
unittest
.
makeSuite
(
TextFileTestCase
)
...
...
Lib/distutils/util.py
Dosyayı görüntüle @
bee5cef7
...
@@ -115,13 +115,15 @@ def get_platform ():
...
@@ -115,13 +115,15 @@ def get_platform ():
# behaviour.
# behaviour.
pass
pass
else
:
else
:
m
=
re
.
search
(
try
:
r'<key>ProductUserVisibleVersion</key>\s*'
+
m
=
re
.
search
(
r'<string>(.*?)</string>'
,
f
.
read
())
r'<key>ProductUserVisibleVersion</key>\s*'
+
f
.
close
()
r'<string>(.*?)</string>'
,
f
.
read
())
if
m
is
not
None
:
if
m
is
not
None
:
macrelease
=
'.'
.
join
(
m
.
group
(
1
)
.
split
(
'.'
)[:
2
])
macrelease
=
'.'
.
join
(
m
.
group
(
1
)
.
split
(
'.'
)[:
2
])
# else: fall back to the default behaviour
# else: fall back to the default behaviour
finally
:
f
.
close
()
if
not
macver
:
if
not
macver
:
macver
=
macrelease
macver
=
macrelease
...
...
Lib/sysconfig.py
Dosyayı görüntüle @
bee5cef7
...
@@ -680,13 +680,16 @@ def get_platform():
...
@@ -680,13 +680,16 @@ def get_platform():
# behaviour.
# behaviour.
pass
pass
else
:
else
:
m
=
re
.
search
(
try
:
r'<key>ProductUserVisibleVersion</key>\s*'
+
m
=
re
.
search
(
r'<string>(.*?)</string>'
,
f
.
read
())
r'<key>ProductUserVisibleVersion</key>\s*'
+
f
.
close
()
r'<string>(.*?)</string>'
,
f
.
read
())
if
m
is
not
None
:
f
.
close
()
macrelease
=
'.'
.
join
(
m
.
group
(
1
)
.
split
(
'.'
)[:
2
])
if
m
is
not
None
:
# else: fall back to the default behaviour
macrelease
=
'.'
.
join
(
m
.
group
(
1
)
.
split
(
'.'
)[:
2
])
# else: fall back to the default behaviour
finally
:
f
.
close
()
if
not
macver
:
if
not
macver
:
macver
=
macrelease
macver
=
macrelease
...
...
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