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
141534e5
Kaydet (Commit)
141534e5
authored
Nis 28, 2008
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix a bug introduced by the warnings rewrite where tracebacks were being
improperly indented. Closes issue #2699.
üst
f30f6e82
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
4 deletions
+47
-4
test_traceback.py
Lib/test/test_traceback.py
+28
-2
_testcapimodule.c
Modules/_testcapimodule.c
+19
-0
traceback.c
Python/traceback.c
+0
-2
No files found.
Lib/test/test_traceback.py
Dosyayı görüntüle @
141534e5
"""Test cases for traceback module"""
"""Test cases for traceback module"""
from
_testcapi
import
test_traceback_print
from
StringIO
import
StringIO
import
sys
import
unittest
import
unittest
from
test.test_support
import
run_unittest
,
is_jython
from
test.test_support
import
run_unittest
,
is_jython
,
Error
import
traceback
import
traceback
try
:
raise
KeyError
except
KeyError
:
type_
,
value
,
tb
=
sys
.
exc_info
()
file_
=
StringIO
()
test_traceback_print
(
tb
,
file_
)
example_traceback
=
file_
.
getvalue
()
else
:
raise
Error
(
"unable to create test traceback string"
)
class
TracebackCases
(
unittest
.
TestCase
):
class
TracebackCases
(
unittest
.
TestCase
):
# For now, a very minimal set of tests. I want to be sure that
# For now, a very minimal set of tests. I want to be sure that
# formatting of SyntaxErrors works based on changes for 2.1.
# formatting of SyntaxErrors works based on changes for 2.1.
...
@@ -154,8 +168,20 @@ def test():
...
@@ -154,8 +168,20 @@ def test():
self
.
assertEqual
(
err
,
[
'None
\n
'
])
self
.
assertEqual
(
err
,
[
'None
\n
'
])
class
TracebackFormatTests
(
unittest
.
TestCase
):
def
test_traceback_indentation
(
self
):
# Make sure that the traceback is properly indented.
tb_lines
=
example_traceback
.
splitlines
()
self
.
assertEquals
(
len
(
tb_lines
),
3
)
banner
,
location
,
source_line
=
tb_lines
self
.
assert_
(
banner
.
startswith
(
'Traceback'
))
self
.
assert_
(
location
.
startswith
(
' File'
))
self
.
assert_
(
source_line
.
startswith
(
'raise'
))
def
test_main
():
def
test_main
():
run_unittest
(
TracebackCases
)
run_unittest
(
TracebackCases
,
TracebackFormatTests
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
141534e5
...
@@ -734,6 +734,24 @@ test_with_docstring(PyObject *self)
...
@@ -734,6 +734,24 @@ test_with_docstring(PyObject *self)
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
/* To test the format of tracebacks as printed out. */
static
PyObject
*
test_traceback_print
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
file
;
PyObject
*
traceback
;
int
result
;
if
(
!
PyArg_ParseTuple
(
args
,
"OO:test_traceback_print"
,
&
traceback
,
&
file
))
return
NULL
;
result
=
PyTraceBack_Print
(
traceback
,
file
);
if
(
result
<
0
)
return
NULL
;
Py_RETURN_NONE
;
}
static
PyMethodDef
TestMethods
[]
=
{
static
PyMethodDef
TestMethods
[]
=
{
{
"raise_exception"
,
raise_exception
,
METH_VARARGS
},
{
"raise_exception"
,
raise_exception
,
METH_VARARGS
},
{
"test_config"
,
(
PyCFunction
)
test_config
,
METH_NOARGS
},
{
"test_config"
,
(
PyCFunction
)
test_config
,
METH_NOARGS
},
...
@@ -774,6 +792,7 @@ static PyMethodDef TestMethods[] = {
...
@@ -774,6 +792,7 @@ static PyMethodDef TestMethods[] = {
#ifdef WITH_THREAD
#ifdef WITH_THREAD
{
"_test_thread_state"
,
test_thread_state
,
METH_VARARGS
},
{
"_test_thread_state"
,
test_thread_state
,
METH_VARARGS
},
#endif
#endif
{
"test_traceback_print"
,
test_traceback_print
,
METH_VARARGS
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Python/traceback.c
Dosyayı görüntüle @
141534e5
...
@@ -222,8 +222,6 @@ tb_displayline(PyObject *f, const char *filename, int lineno, const char *name)
...
@@ -222,8 +222,6 @@ tb_displayline(PyObject *f, const char *filename, int lineno, const char *name)
err
=
PyFile_WriteString
(
linebuf
,
f
);
err
=
PyFile_WriteString
(
linebuf
,
f
);
if
(
err
!=
0
)
if
(
err
!=
0
)
return
err
;
return
err
;
err
=
PyFile_WriteString
(
" "
,
f
);
return
Py_DisplaySourceLine
(
f
,
filename
,
lineno
);
return
Py_DisplaySourceLine
(
f
,
filename
,
lineno
);
}
}
...
...
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