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
ec2fd02b
Kaydet (Commit)
ec2fd02b
authored
Eki 06, 2014
tarafından
Loic Bistuer
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23594 -- Fixed deepcopy on ErrorList.
Thanks Troy Grosfield for the report and Tim Graham for the tests.
üst
1edaa552
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
utils.py
django/forms/utils.py
+9
-0
1.7.1.txt
docs/releases/1.7.1.txt
+2
-0
test_util.py
tests/forms_tests/tests/test_util.py
+23
-0
No files found.
django/forms/utils.py
Dosyayı görüntüle @
ec2fd02b
...
...
@@ -138,6 +138,15 @@ class ErrorList(UserList, list):
return
list
(
error
)[
0
]
return
force_text
(
error
)
def
__reduce_ex__
(
self
,
*
args
,
**
kwargs
):
# The `list` reduce function returns an iterator as the fourth element
# that is normally used for repopulating. Since we only inherit from
# `list` for `isinstance` backward compatibility (Refs #17413) we
# nullify this iterator as it would otherwise result in duplicate
# entries. (Refs #23594)
info
=
super
(
UserList
,
self
)
.
__reduce_ex__
(
*
args
,
**
kwargs
)
return
info
[:
3
]
+
(
None
,
None
)
# Utilities for time zone support in DateTimeField et al.
...
...
docs/releases/1.7.1.txt
Dosyayı görüntüle @
ec2fd02b
...
...
@@ -89,3 +89,5 @@ Bugfixes
* Fixed ``MigrationWriter`` to handle builtin types without imports
(:ticket:`23560`).
* Fixed ``deepcopy`` on ``ErrorList`` (:ticket:`23594`).
tests/forms_tests/tests/test_util.py
Dosyayı görüntüle @
ec2fd02b
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
copy
from
django.core.exceptions
import
ValidationError
from
django.forms.utils
import
flatatt
,
ErrorDict
,
ErrorList
from
django.test
import
TestCase
...
...
@@ -69,3 +71,24 @@ class FormsUtilTestCase(TestCase):
'<ul class="errorlist"><li>nameExample of link: <a href="http://www.example.com/">example</a></li></ul>'
)
self
.
assertHTMLEqual
(
str
(
ErrorDict
({
'name'
:
mark_safe
(
example
)})),
'<ul class="errorlist"><li>nameExample of link: <a href="http://www.example.com/">example</a></li></ul>'
)
def
test_error_dict_copy
(
self
):
e
=
ErrorDict
()
e
[
'__all__'
]
=
ErrorList
([
ValidationError
(
message
=
'message
%(i)
s'
,
params
=
{
'i'
:
1
},
),
ValidationError
(
message
=
'message
%(i)
s'
,
params
=
{
'i'
:
2
},
),
])
e_copy
=
copy
.
copy
(
e
)
self
.
assertEqual
(
e
,
e_copy
)
self
.
assertEqual
(
e
.
as_data
(),
e_copy
.
as_data
())
e_deepcopy
=
copy
.
deepcopy
(
e
)
self
.
assertEqual
(
e
,
e_deepcopy
)
self
.
assertEqual
(
e
.
as_data
(),
e_copy
.
as_data
())
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