Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
756cee46
Kaydet (Commit)
756cee46
authored
Mar 07, 2015
tarafından
Bas Peschier
Kaydeden (comit)
Tim Graham
Mar 10, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24455 -- Fixed crash in debug view with lazy objects
üst
578ac17f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
debug.py
django/views/debug.py
+9
-1
test_debug.py
tests/view_tests/tests/test_debug.py
+31
-0
No files found.
django/views/debug.py
Dosyayı görüntüle @
756cee46
...
...
@@ -186,7 +186,15 @@ class SafeExceptionReporterFilter(ExceptionReporterFilter):
return
request
.
POST
def
cleanse_special_types
(
self
,
request
,
value
):
if
isinstance
(
value
,
HttpRequest
):
try
:
# If value is lazy or a complex object of another kind, this check
# might raise an exception. isinstance checks that lazy HttpRequests
# or MultiValueDicts will have a return value.
is_request
=
isinstance
(
value
,
HttpRequest
)
except
Exception
as
e
:
return
'{!r} while evaluating {!r}'
.
format
(
e
,
value
)
if
is_request
:
# Cleanse the request's POST parameters.
value
=
self
.
get_request_repr
(
value
)
elif
isinstance
(
value
,
MultiValueDict
):
...
...
tests/view_tests/tests/test_debug.py
Dosyayı görüntüle @
756cee46
...
...
@@ -18,6 +18,7 @@ from django.template.base import TemplateDoesNotExist
from
django.test
import
RequestFactory
,
TestCase
,
override_settings
from
django.utils
import
six
from
django.utils.encoding
import
force_bytes
,
force_text
from
django.utils.functional
import
SimpleLazyObject
from
django.views.debug
import
CallableSettingWrapper
,
ExceptionReporter
from
..
import
BrokenException
,
except_args
...
...
@@ -380,6 +381,36 @@ class ExceptionReporterTests(TestCase):
html
=
reporter
.
get_traceback_html
()
self
.
assertIn
(
'<h1>ImportError at /test_view/</h1>'
,
html
)
def
test_ignore_traceback_evaluation_exceptions
(
self
):
"""
Don't trip over exceptions generated by crafted objects when
evaluating them while cleansing (#24455).
"""
class
BrokenEvaluation
(
Exception
):
pass
def
broken_setup
():
raise
BrokenEvaluation
request
=
self
.
rf
.
get
(
'/test_view/'
)
broken_lazy
=
SimpleLazyObject
(
broken_setup
)
try
:
bool
(
broken_lazy
)
except
BrokenEvaluation
:
exc_type
,
exc_value
,
tb
=
sys
.
exc_info
()
reporter
=
ExceptionReporter
(
request
,
exc_type
,
exc_value
,
tb
)
try
:
html
=
reporter
.
get_traceback_html
()
except
BrokenEvaluation
:
self
.
fail
(
"Broken evaluation in traceback is not caught."
)
self
.
assertIn
(
"BrokenEvaluation"
,
html
,
"Evaluation exception reason not mentioned in traceback"
)
class
PlainTextReportTests
(
TestCase
):
rf
=
RequestFactory
()
...
...
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