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
8d109cb0
Kaydet (Commit)
8d109cb0
authored
May 08, 2008
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Antoine Pitrou's patch for bug 2507; exception state lives too long in
3.0.
üst
96de30ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
test_exceptions.py
Lib/test/test_exceptions.py
+29
-2
ceval.c
Python/ceval.c
+13
-0
No files found.
Lib/test/test_exceptions.py
Dosyayı görüntüle @
8d109cb0
...
@@ -4,6 +4,7 @@ import os
...
@@ -4,6 +4,7 @@ import os
import
sys
import
sys
import
unittest
import
unittest
import
pickle
import
pickle
import
weakref
from
test.test_support
import
TESTFN
,
unlink
,
run_unittest
from
test.test_support
import
TESTFN
,
unlink
,
run_unittest
...
@@ -400,8 +401,9 @@ class ExceptionTests(unittest.TestCase):
...
@@ -400,8 +401,9 @@ class ExceptionTests(unittest.TestCase):
self
.
failUnless
(
str
(
Exception
(
'a'
)))
self
.
failUnless
(
str
(
Exception
(
'a'
)))
self
.
failUnless
(
str
(
Exception
(
'a'
)))
self
.
failUnless
(
str
(
Exception
(
'a'
)))
def
testExceptionCleanup
(
self
):
def
testExceptionCleanupNames
(
self
):
# Make sure "except V as N" exceptions are cleaned up properly
# Make sure the local variable bound to the exception instance by
# an "except" statement is only visible inside the except block.
try
:
try
:
raise
Exception
()
raise
Exception
()
...
@@ -410,6 +412,31 @@ class ExceptionTests(unittest.TestCase):
...
@@ -410,6 +412,31 @@ class ExceptionTests(unittest.TestCase):
del
e
del
e
self
.
failIf
(
'e'
in
locals
())
self
.
failIf
(
'e'
in
locals
())
def
testExceptionCleanupState
(
self
):
# Make sure exception state is cleaned up as soon as the except
# block is left. See #2507
class
MyException
(
Exception
):
def
__init__
(
self
,
obj
):
self
.
obj
=
obj
class
MyObj
:
pass
def
inner_raising_func
():
# Create some references in exception value and traceback
local_ref
=
obj
raise
MyException
(
obj
)
obj
=
MyObj
()
wr
=
weakref
.
ref
(
obj
)
try
:
inner_raising_func
()
except
MyException
as
e
:
pass
obj
=
None
obj
=
wr
()
self
.
failUnless
(
obj
is
None
,
"
%
s"
%
obj
)
def
test_main
():
def
test_main
():
run_unittest
(
ExceptionTests
)
run_unittest
(
ExceptionTests
)
...
...
Python/ceval.c
Dosyayı görüntüle @
8d109cb0
...
@@ -1477,6 +1477,19 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1477,6 +1477,19 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
"'finally' pops bad exception"
);
"'finally' pops bad exception"
);
why
=
WHY_EXCEPTION
;
why
=
WHY_EXCEPTION
;
}
}
/*
Make sure the exception state is cleaned up before
the end of an except block. This ensures objects
referenced by the exception state are not kept
alive too long.
See #2507.
*/
if
(
tstate
->
frame
->
f_exc_type
!=
NULL
)
reset_exc_info
(
tstate
);
else
{
assert
(
tstate
->
frame
->
f_exc_value
==
NULL
);
assert
(
tstate
->
frame
->
f_exc_traceback
==
NULL
);
}
Py_DECREF
(
v
);
Py_DECREF
(
v
);
break
;
break
;
...
...
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