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
d1c3c13f
Kaydet (Commit)
d1c3c13f
authored
May 25, 2017
tarafından
Eric Snow
Kaydeden (comit)
GitHub
May 25, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30447: Fix/skip the subinterpreters test on some platforms. (#1791)
üst
94987826
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
44 deletions
+43
-44
test_capi.py
Lib/test/test_capi.py
+42
-43
_testembed.c
Programs/_testembed.c
+1
-1
No files found.
Lib/test/test_capi.py
Dosyayı görüntüle @
d1c3c13f
...
@@ -385,7 +385,7 @@ class EmbeddingTests(unittest.TestCase):
...
@@ -385,7 +385,7 @@ class EmbeddingTests(unittest.TestCase):
(
p
.
returncode
,
err
))
(
p
.
returncode
,
err
))
return
out
,
err
return
out
,
err
def
test_subinterp
s
(
self
):
def
run_repeated_init_and_subinterpreter
s
(
self
):
out
,
err
=
self
.
run_embedded_interpreter
(
"repeated_init_and_subinterpreters"
)
out
,
err
=
self
.
run_embedded_interpreter
(
"repeated_init_and_subinterpreters"
)
self
.
assertEqual
(
err
,
""
)
self
.
assertEqual
(
err
,
""
)
...
@@ -404,73 +404,72 @@ class EmbeddingTests(unittest.TestCase):
...
@@ -404,73 +404,72 @@ class EmbeddingTests(unittest.TestCase):
r"id\(modules\) = ([\d]+)$"
)
r"id\(modules\) = ([\d]+)$"
)
Interp
=
namedtuple
(
"Interp"
,
"id interp tstate modules"
)
Interp
=
namedtuple
(
"Interp"
,
"id interp tstate modules"
)
main
=
None
lastmain
=
None
numinner
=
None
numloops
=
0
numloops
=
0
current_run
=
[]
for
line
in
out
.
splitlines
():
for
line
in
out
.
splitlines
():
if
line
==
"--- Pass {} ---"
.
format
(
numloops
):
if
line
==
"--- Pass {} ---"
.
format
(
numloops
):
if
numinner
is
not
None
:
self
.
assertEqual
(
len
(
current_run
),
0
)
self
.
assertEqual
(
numinner
,
5
)
if
support
.
verbose
:
if
support
.
verbose
:
print
(
line
)
print
(
line
)
lastmain
=
main
main
=
None
mainid
=
0
numloops
+=
1
numloops
+=
1
numinner
=
0
continue
continue
numinner
+=
1
self
.
assertLess
Equal
(
numinner
,
5
)
self
.
assertLess
(
len
(
current_run
)
,
5
)
match
=
re
.
match
(
interp_pat
,
line
)
match
=
re
.
match
(
interp_pat
,
line
)
if
match
is
None
:
if
match
is
None
:
self
.
assertRegex
(
line
,
interp_pat
)
self
.
assertRegex
(
line
,
interp_pat
)
# The last line in the loop should be the same as the first.
if
numinner
==
5
:
self
.
assertEqual
(
match
.
groups
(),
main
)
continue
# Parse the line from the loop. The first line is the main
# Parse the line from the loop. The first line is the main
# interpreter and the 3 afterward are subinterpreters.
# interpreter and the 3 afterward are subinterpreters.
interp
=
Interp
(
*
match
.
groups
())
interp
=
Interp
(
*
match
.
groups
())
if
support
.
verbose
:
if
support
.
verbose
:
print
(
interp
)
print
(
interp
)
if
numinner
==
1
:
main
=
interp
id
=
str
(
mainid
)
else
:
subid
=
mainid
+
numinner
-
1
id
=
str
(
subid
)
# Validate the loop line for each interpreter.
self
.
assertEqual
(
interp
.
id
,
id
)
self
.
assertTrue
(
interp
.
interp
)
self
.
assertTrue
(
interp
.
interp
)
self
.
assertTrue
(
interp
.
tstate
)
self
.
assertTrue
(
interp
.
tstate
)
self
.
assertTrue
(
interp
.
modules
)
self
.
assertTrue
(
interp
.
modules
)
if
platform
.
system
()
==
'Windows'
:
current_run
.
append
(
interp
)
# XXX Fix on Windows: something is going on with the
# pointers in Programs/_testembed.c. interp.interp
# The last line in the loop should be the same as the first.
# is 0x0 and # interp.modules is the same between
if
len
(
current_run
)
==
5
:
# interpreters.
main
=
current_run
[
0
]
continue
self
.
assertEqual
(
interp
,
main
)
if
interp
is
main
:
yield
current_run
if
lastmain
is
not
None
:
current_run
=
[]
# A new main interpreter may have the same interp
# and/or tstate pointer as an earlier finalized/
def
test_subinterps_main
(
self
):
# destroyed one. So we do not check interp or
for
run
in
self
.
run_repeated_init_and_subinterpreters
():
# tstate here.
main
=
run
[
0
]
self
.
assertNotEqual
(
interp
.
modules
,
lastmain
.
modules
)
else
:
self
.
assertEqual
(
main
.
id
,
'0'
)
def
test_subinterps_different_ids
(
self
):
for
run
in
self
.
run_repeated_init_and_subinterpreters
():
main
,
*
subs
,
_
=
run
mainid
=
int
(
main
.
id
)
for
i
,
sub
in
enumerate
(
subs
):
self
.
assertEqual
(
sub
.
id
,
str
(
mainid
+
i
+
1
))
def
test_subinterps_distinct_state
(
self
):
for
run
in
self
.
run_repeated_init_and_subinterpreters
():
main
,
*
subs
,
_
=
run
if
'0x0'
in
main
:
# XXX Fix on Windows (and other platforms): something
# is going on with the pointers in Programs/_testembed.c.
# interp.interp is 0x0 and interp.modules is the same
# between interpreters.
raise
unittest
.
SkipTest
(
'platform prints pointers as 0x0'
)
for
sub
in
subs
:
# A new subinterpreter may have the same
# A new subinterpreter may have the same
# PyInterpreterState pointer as a previous one if
# PyInterpreterState pointer as a previous one if
# the earlier one has already been destroyed. So
# the earlier one has already been destroyed. So
# we compare with the main interpreter. The same
# we compare with the main interpreter. The same
# applies to tstate.
# applies to tstate.
self
.
assertNotEqual
(
interp
.
interp
,
main
.
interp
)
self
.
assertNotEqual
(
sub
.
interp
,
main
.
interp
)
self
.
assertNotEqual
(
interp
.
tstate
,
main
.
tstate
)
self
.
assertNotEqual
(
sub
.
tstate
,
main
.
tstate
)
self
.
assertNotEqual
(
interp
.
modules
,
main
.
modules
)
self
.
assertNotEqual
(
sub
.
modules
,
main
.
modules
)
@staticmethod
@staticmethod
def
_get_default_pipe_encoding
():
def
_get_default_pipe_encoding
():
...
...
Programs/_testembed.c
Dosyayı görüntüle @
d1c3c13f
...
@@ -28,7 +28,7 @@ static void print_subinterp(void)
...
@@ -28,7 +28,7 @@ static void print_subinterp(void)
PyThreadState
*
ts
=
PyThreadState_Get
();
PyThreadState
*
ts
=
PyThreadState_Get
();
PyInterpreterState
*
interp
=
ts
->
interp
;
PyInterpreterState
*
interp
=
ts
->
interp
;
int64_t
id
=
PyInterpreterState_GetID
(
interp
);
int64_t
id
=
PyInterpreterState_GetID
(
interp
);
printf
(
"interp %
lu
<0x%"
PRIXPTR
">, thread state <0x%"
PRIXPTR
">: "
,
printf
(
"interp %
"
PRId64
"
<0x%"
PRIXPTR
">, thread state <0x%"
PRIXPTR
">: "
,
id
,
(
uintptr_t
)
interp
,
(
uintptr_t
)
ts
);
id
,
(
uintptr_t
)
interp
,
(
uintptr_t
)
ts
);
fflush
(
stdout
);
fflush
(
stdout
);
PyRun_SimpleString
(
PyRun_SimpleString
(
...
...
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