Message146598
I just realized the builtin function `vars` can't handle custom objects without the __dict__ attribute.
It would be nice if it worked with objects that have __slots__ to make them look more like normal objects and to make debugging easier.
I changed the source of "Python/bltinmodule.c" to accept this new case, but, as I'm fairly new to the C API, it may not be much good.
I'm attaching the whole file to this Issue and the `builtin_vars` function was modified (lines 1859 to 1921) to work with:
__slots__ = ('a', 'b', 'c')
__slots__ = 'single_name'
__slots__ = {'some': 'mapping'}
The output is a dict (just like in the __dict__ case).
#Example
>>> class C:
__slots__ = ['x', 'y']
>>> c = C()
>>> c.x = 123
>>> vars(c)
{'x': 123} |
|
Date |
User |
Action |
Args |
2011-10-29 07:04:12 | JBernardo | set | recipients:
+ JBernardo |
2011-10-29 07:04:10 | JBernardo | set | messageid: <1319871850.77.0.869546838833.issue13290@psf.upfronthosting.co.za> |
2011-10-29 07:04:10 | JBernardo | link | issue13290 messages |
2011-10-29 07:04:09 | JBernardo | create | |
|