Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1367 (closed defect: fixed)

Opened 12 years ago

Last modified 9 years ago

[PATCH] i18n.tg_gettext.lazystring needs __deepcopy__

Reported by: cvogler Owned by: anonymous
Priority: normal Milestone: 1.0.x bugfix
Component: TurboGears Version: 1.0.1
Severity: normal Keywords:
Cc:

Description

Given the following code:

#!/usr/bin/env python
from turbogears import widgets as w, validators as v

class MySchema(v.Schema):
    list = v.IndexListConverter(list=[_("str1"), _("str2")])
class MyWidget(w.WidgetsList):
    list=w.TextField()
widget = w.TableForm(fields=MyWidget(), name="mywidget", action="save",
                     method="post", validator=MySchema())

I get an error with the following traceback:

Traceback (most recent call last):
  File "./test.py", line 9, in ?
    method="post", validator=MySchema())
  File "/home/cvogler/src/taubenschlag/aggregator/turbogears/lib/python2.4/TurboGears-1.0.1-py2.4.egg/turbogears/widgets/meta.py", line 168, in widget_init
    validator = generate_schema(self.validator, widgets)
  File "/home/cvogler/src/taubenschlag/aggregator/turbogears/lib/python2.4/TurboGears-1.0.1-py2.4.egg/turbogears/widgets/meta.py", line 265, in generate_schema
    schema = copy_schema(schema)
  File "/home/cvogler/src/taubenschlag/aggregator/turbogears/lib/python2.4/TurboGears-1.0.1-py2.4.egg/turbogears/widgets/meta.py", line 210, in copy_schema
    return copy.deepcopy(schema)
  File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.4/copy.py", line 351, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.4/copy.py", line 351, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.4/copy.py", line 241, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.4/copy.py", line 351, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.4/copy.py", line 336, in _reconstruct
    y = callable(*args)
  File "/usr/lib/python2.4/copy_reg.py", line 92, in __newobj__
    return cls.__new__(cls, *args)
TypeError: function() takes at least 2 arguments (0 given)

The attached patch fixes the problem for me. Please check my assumptions here: the patch assumes that lazystring objects can be shared, just like regular strings can, and are effectively immutable.

Attachments

tg-deepcopy.diff Download (415 bytes) - added by cvogler 12 years ago.
The previous patch had a whitespace problem - this version should now apply cleanly

Change History

Changed 12 years ago by cvogler

The previous patch had a whitespace problem - this version should now apply cleanly

comment:1 Changed 12 years ago by faide

  • Status changed from new to closed
  • Resolution set to fixed

Applied thanks!

comment:2 Changed 9 years ago by chrisz

  • Milestone changed from __unclassified__ to 1.0.x bugfix
Note: See TracTickets for help on using tickets.