Bug hunting in rctime becomes wtf
![](https://secure.gravatar.com/avatar/68b184c61eac5ccf10b4a84b98a190c1.jpg?s=120&d=mm&r=g)
I had a nasty bug like this one in the compilation process of the rctime module: [translation:ERROR] Error: [translation:ERROR] TyperError: non-constant tuple index [translation:ERROR] .. block@34 with 1 exits [translation:ERROR] .. v0 = getitem(tup_0, ___i_0) You can reproduce it decommenting asctime function from interp_time.py and in the __init__.py file of the rctime module. After some digging I've found the source of the problem in the code Armin and I have checked-in at the sprint to add the support for "*args" arguments (see visit_args_w in pypy.objspace.cpy.function). I tried patching it but I'm not very into cpy objspace and the compiler mechanism under the hood. The "wtf" thing came out when I tried to use the file with this "stupid" patch applied: rhymes@groove:~/scc/pypy/pypy/objspace/cpy $ svn diff Index: function.py =================================================================== --- function.py (revision 29953) +++ function.py (working copy) @@ -61,7 +61,7 @@ tramp.inputargs.append('*' + basename) tramp.wrappings.append('%s = []' % (argname,)) tramp.wrappings.append('for ___i in range(len(%s)):' % (basename,)) - tramp.wrappings.append(' %s.append(___W_Object(%s[___i]))' % ( + tramp.wrappings.append(' %s.append(___W_Object(%s[0]))' % ( argname, basename)) tramp.passedargs.append(argname) The thing surprised me is the compilation after the patch goes fine and (!!) the module works correctly. asctime() does it's dirty job. So, why does it work? -- Lawrence http://www.oluyede.org/blog
participants (1)
-
Lawrence Oluyede