I don’t know why, but I’ve been hitting roadblocks all day about fix_metaclass. I’m not going to commit the trash I have, because I will probably start over completely on it. I think I’m trying to rely too much on the pattern compiler; I should probably be mimicking 2to3′s fix_metaclass and use the PATTERN to match all classdefs, then call some of my own functions to narrow it down… but I keep trying to mess around with the PATTERN to match a class with a metaclass; I know it’s possible, I just can’t get it to work. So tonight I’ll start over on it, and hopefully it’ll be done tomorrow.
June 16, 2009
3 Comments »
RSS feed for comments on this post. TrackBack URL
Yeah, usually it’s best to just start over. That as well as getting some food and fresh air
Comment by Runa — June 17, 2009 @ 11:34 am
So I’ve restarted on this. It’s not finished yet, but I’ve made considerable progress (commit-worthy: even though it doesn’t work yet, it does successfully identify and remove the original metaclass=X from the classdef, then construct a proper assignment statement… all that’s left to do is to insert that statement into the suite)
Comment by AirBreather — June 22, 2009 @ 3:09 pm
There it is. Metaclass fix works now (syntactically). Semantically, it might be able to do with a makeover, but hey, it works.
This example represents a couple of things that the fixer could do that it doesn’t at this point:
class foo(metaclass=bar): passfixes into
class foo():. __metaclass__ = bar
. pass
instead of the prettier
class foo(): __metaclass__ = bar
Comment by AirBreather — June 30, 2009 @ 1:02 am