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
ff881aef
Kaydet (Commit)
ff881aef
authored
May 18, 2013
tarafından
Shai Berger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #13958 -- problem reporting exception from \r-line-ended file
Thanks petrvanblokland for reporting and saz for the patch
üst
2c84f443
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
debug.py
django/views/debug.py
+4
-4
test_debug.py
tests/view_tests/tests/test_debug.py
+20
-1
No files found.
django/views/debug.py
Dosyayı görüntüle @
ff881aef
...
...
@@ -347,7 +347,7 @@ class ExceptionReporter(object):
if
source
is
None
:
try
:
with
open
(
filename
,
'rb'
)
as
fp
:
source
=
fp
.
readlines
()
source
=
fp
.
read
()
.
split
lines
()
except
(
OSError
,
IOError
):
pass
if
source
is
None
:
...
...
@@ -370,9 +370,9 @@ class ExceptionReporter(object):
lower_bound
=
max
(
0
,
lineno
-
context_lines
)
upper_bound
=
lineno
+
context_lines
pre_context
=
[
line
.
strip
(
'
\n
'
)
for
line
in
source
[
lower_bound
:
lineno
]
]
context_line
=
source
[
lineno
]
.
strip
(
'
\n
'
)
post_context
=
[
line
.
strip
(
'
\n
'
)
for
line
in
source
[
lineno
+
1
:
upper_bound
]
]
pre_context
=
source
[
lower_bound
:
lineno
]
context_line
=
source
[
lineno
]
post_context
=
source
[
lineno
+
1
:
upper_bound
]
return
lower_bound
,
pre_context
,
context_line
,
post_context
...
...
tests/view_tests/tests/test_debug.py
Dosyayı görüntüle @
ff881aef
...
...
@@ -6,6 +6,7 @@ from __future__ import absolute_import, unicode_literals
import
inspect
import
os
import
sys
import
tempfile
from
django.core
import
mail
from
django.core.files.uploadedfile
import
SimpleUploadedFile
...
...
@@ -13,7 +14,7 @@ from django.core.urlresolvers import reverse
from
django.test
import
TestCase
,
RequestFactory
from
django.test.utils
import
(
override_settings
,
setup_test_template_loader
,
restore_template_loaders
)
from
django.utils.encoding
import
force_text
from
django.utils.encoding
import
force_text
,
force_bytes
from
django.views.debug
import
ExceptionReporter
from
..
import
BrokenException
,
except_args
...
...
@@ -122,6 +123,24 @@ class ExceptionReporterTests(TestCase):
self
.
assertIn
(
'<h2>Request information</h2>'
,
html
)
self
.
assertIn
(
'<p>Request data not supplied</p>'
,
html
)
def
test_eol_support
(
self
):
"""Test that the ExceptionReporter supports Unix, Windows and Macintosh EOL markers"""
LINES
=
list
(
u'print
%
d'
%
i
for
i
in
range
(
1
,
6
))
reporter
=
ExceptionReporter
(
None
,
None
,
None
,
None
)
for
newline
in
[
'
\n
'
,
'
\r\n
'
,
'
\r
'
]:
fd
,
filename
=
tempfile
.
mkstemp
(
text
=
False
)
os
.
write
(
fd
,
force_bytes
(
newline
.
join
(
LINES
)
+
newline
))
os
.
close
(
fd
)
try
:
self
.
assertEqual
(
reporter
.
_get_lines_from_file
(
filename
,
3
,
2
),
(
1
,
LINES
[
1
:
3
],
LINES
[
3
],
LINES
[
4
:])
)
finally
:
os
.
unlink
(
filename
)
def
test_no_exception
(
self
):
"An exception report can be generated for just a request"
request
=
self
.
rf
.
get
(
'/test_view/'
)
...
...
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