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
e19cadb4
Kaydet (Commit)
e19cadb4
authored
Tem 31, 2008
tarafından
Amaury Forgeot d'Arc
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Correct one of the "MemoryError oddities":
the traceback would grow each time a MemoryError is raised.
üst
a986dfa9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
test_exceptions.py
Lib/test/test_exceptions.py
+18
-0
errors.c
Python/errors.c
+10
-0
No files found.
Lib/test/test_exceptions.py
Dosyayı görüntüle @
e19cadb4
...
@@ -596,6 +596,24 @@ class ExceptionTests(unittest.TestCase):
...
@@ -596,6 +596,24 @@ class ExceptionTests(unittest.TestCase):
"Exception ValueError: ValueError() "
"Exception ValueError: ValueError() "
"in <class 'KeyError'> ignored
\n
"
)
"in <class 'KeyError'> ignored
\n
"
)
def
test_MemoryError
(
self
):
# PyErr_NoMemory always raises the same exception instance.
# Check that the traceback is not doubled.
import
traceback
def
raiseMemError
():
try
:
"a"
*
(
sys
.
maxsize
//
2
)
except
MemoryError
as
e
:
tb
=
e
.
__traceback__
else
:
self
.
fail
(
"Should have raises a MemoryError"
)
return
traceback
.
format_tb
(
tb
)
tb1
=
raiseMemError
()
tb2
=
raiseMemError
()
self
.
assertEqual
(
tb1
,
tb2
)
def
test_main
():
def
test_main
():
run_unittest
(
ExceptionTests
)
run_unittest
(
ExceptionTests
)
...
...
Python/errors.c
Dosyayı görüntüle @
e19cadb4
...
@@ -321,7 +321,17 @@ PyErr_NoMemory(void)
...
@@ -321,7 +321,17 @@ PyErr_NoMemory(void)
/* raise the pre-allocated instance if it still exists */
/* raise the pre-allocated instance if it still exists */
if
(
PyExc_MemoryErrorInst
)
if
(
PyExc_MemoryErrorInst
)
{
/* Clear the previous traceback, otherwise it will be appended
* to the current one.
*
* The following statement is not likely to raise any error;
* if it does, we simply discard it.
*/
PyException_SetTraceback
(
PyExc_MemoryErrorInst
,
Py_None
);
PyErr_SetObject
(
PyExc_MemoryError
,
PyExc_MemoryErrorInst
);
PyErr_SetObject
(
PyExc_MemoryError
,
PyExc_MemoryErrorInst
);
}
else
else
/* this will probably fail since there's no memory and hee,
/* this will probably fail since there's no memory and hee,
hee, we have to instantiate this class
hee, we have to instantiate this class
...
...
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