copy.deepcopy for newforms' Bug ?

8 views
Skip to first unread message

张沈鹏(电子科大08年本科应届)

unread,
Sep 14, 2007, 11:00:17 PM9/14/07
to django-d...@googlegroups.com
When I checkout django from svn , this error happened , it seems come from #6154

..................
File "D:\myWay\stuhome_django\sdk\python\Lib\site-packages\django\newforms\forms.py"
in __init__
76. self.fields = self.base_fields.copy()
File "D:\myWay\stuhome_django\sdk\python\Lib\site-packages\django\newforms\forms.py"
in copy
34. return SortedDictFromList([(k, copy.deepcopy(v)) for k, v in
self.items()])
File "D:\myWay\stuhome_django\sdk\python\Lib\site-packages\django\newforms\fields.py"
in __deepcopy__
107. result.widget = copy.deepcopy(self.widget, memo)

TypeError at /accounts/details/
object.__new__(method_descriptor) is not safe, use method_descriptor.__new__()

--


博客:http://zsp.javaeye.com/
专业:生物医学工程+计算机科学与技术
技能:C++(STL,BOOST) Python(Django) HTML+CSS AJAX
-- 张沈鹏

Malcolm Tredinnick

unread,
Sep 15, 2007, 12:20:20 AM9/15/07
to django-d...@googlegroups.com
On Sat, 2007-09-15 at 11:00 +0800, 张沈鹏(电子科大08年本科应届) wrote:
> When I checkout django from svn , this error happened , it seems come from #6154
>
> ..................
> File "D:\myWay\stuhome_django\sdk\python\Lib\site-packages\django\newforms\forms.py"
> in __init__
> 76. self.fields = self.base_fields.copy()
> File "D:\myWay\stuhome_django\sdk\python\Lib\site-packages\django\newforms\forms.py"
> in copy
> 34. return SortedDictFromList([(k, copy.deepcopy(v)) for k, v in
> self.items()])
> File "D:\myWay\stuhome_django\sdk\python\Lib\site-packages\django\newforms\fields.py"
> in __deepcopy__
> 107. result.widget = copy.deepcopy(self.widget, memo)
>
> TypeError at /accounts/details/
> object.__new__(method_descriptor) is not safe, use method_descriptor.__new__()

If you can create a simple example that repeats the problem, could you
open a ticket in Trac and attach the example, please.

We changed some stuff in this area yesterday to fix another problem, but
getting deepcopying of dynamic classes right is tricky, so there may
well be an edge-case we've missed. Give us a way to repeat the problem
and I'll gladly take a look at it.

Thanks,
Malcolm

--
Experience is something you don't get until just after you need it.
http://www.pointy-stick.com/blog/

张沈鹏(电子科大08年本科应届)

unread,
Sep 15, 2007, 4:17:26 AM9/15/07
to django-d...@googlegroups.com
I tried to open a ticket , but the Trac detected an internal error
when I try to append the attachment .
the example is in this email's attachment, please have a look


Below is the Trac error(oops)

Trac detected an internal error:

If you think this really should work and you can reproduce it, you
should consider reporting this problem to the Trac team.

Go to http://trac.edgewall.org/ and create a new ticket where you
describe the problem, how to reproduce it. Don't forget to include the
Python traceback found below.

TracGuide -- The Trac User and Administration Guide
Python Traceback

Traceback (most recent call last):
File "/home/trac/new-djangoproject-trac-test/trac/web/main.py", line
387, in dispatch_request
File "/home/trac/new-djangoproject-trac-test/trac/web/main.py", line
237, in dispatch
File "/home/trac/new-djangoproject-trac-test/trac/attachment.py",
line 361, in process_request
File "/home/trac/new-djangoproject-trac-test/trac/attachment.py",
line 475, in _do_save
File "build/bdist.linux-i686/egg/tracspamfilter/adapters.py", line
130, in validate_attachment
File "build/bdist.linux-i686/egg/tracspamfilter/api.py", line 131, in test
File "build/bdist.linux-i686/egg/tracspamfilter/model.py", line 119, in insert
File "/home/trac/new-djangoproject-trac-test/trac/db/util.py", line
50, in execute
File "/home/trac/new-djangoproject-trac-test/trac/db/util.py", line
50, in execute
File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 3083,
in execute
parms = _quoteall(self.__unicodeConvert(parms[0]))
File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 2300,
in _quoteall
t = tuple(map(_quote, vdict))
File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 2268, in _quote
return PgQuoteString(value)
TypeError: PgQuoteString() argument 1 must be string without null bytes, not str

2007/9/15, Malcolm Tredinnick <mal...@pointy-stick.com>:

simple.zip

Malcolm Tredinnick

unread,
Sep 15, 2007, 4:46:29 AM9/15/07
to django-d...@googlegroups.com
On Sat, 2007-09-15 at 16:17 +0800, 张沈鹏(电子科大08年本科应届) wrote:
> I tried to open a ticket , but the Trac detected an internal error
> when I try to append the attachment .

Trac doesn't like binary uploads (like zip files).

Still, thanks for putting together such a small example. I'll be able to
do something with this.

Regards,
Malcolm

--
Success always occurs in private and failure in full view.
http://www.pointy-stick.com/blog/

andybak

unread,
Sep 17, 2007, 12:39:49 PM9/17/07
to Django developers
>From my experience and a post on Django-users I think this has also
broken the newforms-admin change and add pages.

On Sep 15, 9:46 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Joseph Kocherhans

unread,
Sep 17, 2007, 12:53:15 PM9/17/07
to django-d...@googlegroups.com
On 9/17/07, andybak <and...@gmail.com> wrote:
>
> >From my experience and a post on Django-users I think this has also
> broken the newforms-admin change and add pages.

It appears that newforms-admin add and change pages are broken if your
model has a ForeignKey or ManyToManyField that isn't in raw_id_fields.
I haven't seen if the patch(es) in #5505 fix it though.

[6342] is the changeset that triggers the breakage. I haven't dug
through it yet though. It's the first post-friday merge of trunk into
newforms-admin, so there's a lot there. I'll take a look tonight.

Joseph

Reply all
Reply to author
Forward
0 new messages