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
28a57134
Kaydet (Commit)
28a57134
authored
Eyl 08, 2013
tarafından
Baptiste Mispelon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix #20745: Don't silence TypeError raised inside templates.
Thanks to robin for the report and claudep for the review.
üst
9d115225
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
base.py
django/template/base.py
+8
-5
1.7.txt
docs/releases/1.7.txt
+3
-0
tests.py
tests/template_tests/tests.py
+6
-0
No files found.
django/template/base.py
Dosyayı görüntüle @
28a57134
...
...
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
import
re
from
functools
import
partial
from
importlib
import
import_module
from
inspect
import
getargspec
from
inspect
import
getargspec
,
getcallargs
from
django.conf
import
settings
from
django.template.context
import
(
BaseContext
,
Context
,
RequestContext
,
...
...
@@ -788,10 +788,13 @@ class Variable(object):
else
:
try
:
# method call (assuming no args required)
current
=
current
()
except
TypeError
:
# arguments *were* required
# GOTCHA: This will also catch any TypeError
# raised in the function itself.
current
=
settings
.
TEMPLATE_STRING_IF_INVALID
# invalid method call
except
TypeError
:
try
:
getcallargs
(
current
)
except
TypeError
:
# arguments *were* required
current
=
settings
.
TEMPLATE_STRING_IF_INVALID
# invalid method call
else
:
raise
except
Exception
as
e
:
if
getattr
(
e
,
'silent_variable_failure'
,
False
):
current
=
settings
.
TEMPLATE_STRING_IF_INVALID
...
...
docs/releases/1.7.txt
Dosyayı görüntüle @
28a57134
...
...
@@ -282,6 +282,9 @@ Templates
:setting:`TEMPLATE_DEBUG` is ``True``. This allows template origins to be
inspected and logged outside of the ``django.template`` infrastructure.
* ``TypeError`` exceptions are not longer silenced when raised during the
rendering of a template.
Backwards incompatible changes in 1.7
=====================================
...
...
tests/template_tests/tests.py
Dosyayı görüntüle @
28a57134
...
...
@@ -98,6 +98,9 @@ class SomeClass:
def
method4
(
self
):
raise
SomeOtherException
def
method5
(
self
):
raise
TypeError
def
__getitem__
(
self
,
key
):
if
key
==
'silent_fail_key'
:
raise
SomeException
...
...
@@ -680,6 +683,9 @@ class TemplateTests(TransRealMixin, TestCase):
# Fail silently when accessing a non-simple method
'basic-syntax20'
:
(
"{{ var.method2 }}"
,
{
"var"
:
SomeClass
()},
(
""
,
"INVALID"
)),
# Don't silence a TypeError if it was raised inside a callable
'basic-syntax20b'
:
(
"{{ var.method5 }}"
,
{
"var"
:
SomeClass
()},
TypeError
),
# Don't get confused when parsing something that is almost, but not
# quite, a template tag.
'basic-syntax21'
:
(
"a {{ moo
%
} b"
,
{},
"a {{ moo
%
} b"
),
...
...
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