Changes between Initial Version and Version 2 of Ticket #101
- Timestamp:
- 11/10/08 09:44:47 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #101 – Description
initial v2 1 If I try to define a custom __slots__ for a subclass of YAMLObject I get errors during serialization because the code tries to use instance.__dict__.update, but __dict__doesn't exist on objects with slots.1 If I try to define a custom {{{__slots__}}} for a subclass of {{{YAMLObject}}} I get errors during serialization because the code tries to use {{{instance.__dict__.update}}}, but {{{__dict__}}} doesn't exist on objects with slots. 2 2 3 3 {{{ 4 5 6 4 File "/usr/lib/python2.4/site-packages/yaml/__init__.py", line 177, in dump 7 5 return dump_all([data], stream, Dumper=Dumper, **kwds) … … 19 17 }}} 20 18 21 Attached is a patch that makes the constructor use setattr and the representer use __slots__ if __dict__ is not available. I did not write unit tests, as I couldn't figure out how to run them, but it makes the unit tests for my own project (which uses __slots__ for some objects and __dict__for others) pass.19 Attached is a patch that makes the constructor use {{{setattr}}} and the representer use {{{__slots__}}} if {{{__dict__}}} is not available. I did not write unit tests, as I couldn't figure out how to run them, but it makes the unit tests for my own project (which uses {{{__slots__}}} for some objects and {{{__dict__}}} for others) pass.
