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.
File "/usr/lib/python2.4/site-packages/yaml/__init__.py", line 177, in dump
return dump_all([data], stream, Dumper=Dumper, **kwds)
File "/usr/lib/python2.4/site-packages/yaml/__init__.py", line 167, in dump_all
dumper.represent(data)
File "/usr/lib/python2.4/site-packages/yaml/representer.py", line 33, in represent
node = self.represent_data(data)
File "/usr/lib/python2.4/site-packages/yaml/representer.py", line 62, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "/home/piman/code/layer/layer/parse.py", line 84, in __to_yaml
return dumper.represent_yaml_object(
File "/usr/lib/python2.4/site-packages/yaml/representer.py", line 248, in represent_yaml_object
state = data.__dict__.copy()
AttributeError: 'NPoint' object has no attribute '__dict__'
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.