Todays Trivia: kivy.lang.BuilderException: Parser:

177 views
Skip to first unread message

T500

unread,
Oct 31, 2012, 7:27:11 PM10/31/12
to kivy-...@googlegroups.com
Its one of those stupid points of observation that you see from time to time. Its existence is unlikely to influence anything in the whole wide universe... but it does exists :)

Indeed the error below is in line 74 to all known editor programs on my system, yet highlighted >> line 73:

Sorry its not life changing and trivial in the grand scheme of things. But truthfully and honestly, did anyone notice or even care for that matter?


   File "/usr/local/lib/python2.7/site-packages/Kivy-1.4.1-py2.7-linux-x86_64.egg/kivy/lang.py", line 1032, in create_handler
     
raise BuilderException(rule.ctx, rule.line, str(e))
 kivy
.lang.BuilderException: Parser: File "./scr.kv", line 74:
 
...
     
70:            Button:
     
71:                text: str(self.size)
     
72:        Widget:
 
>>   73:            size_hint: (None, Garbage )
     
74:
     
75:
 
...
 name
'Garbage' is not defined

Sorry, just a little hearted post about those small things that often escape our attention :)

Gabriel Pettier

unread,
Oct 31, 2012, 8:06:24 PM10/31/12
to kivy-...@googlegroups.com
Ah, off-by-one is always so much fun :)

patch welcome! :P

Le jeu. 01 nov. 2012 00:27:11 CET, T500 a écrit :
> Its one of those stupid points of observation that you see from time
> to time. Its existence is unlikely to influence anything in the whole
> wide universe... but it does exists :)
>
> Indeed the error below is in line 74 to all known editor programs on
> my system, yet highlighted >> line 73:
>
> Sorry its not life changing and trivial in the grand scheme of
> things. But truthfully and honestly, did anyone notice or even care
> for that matter?
>
>
> |
> File"/usr/local/lib/python2.7/site-packages/Kivy-1.4.1-py2.7-linux-x86_64.egg/kivy/lang.py",line
> 1032,increate_handler
> raiseBuilderException(rule.ctx,rule.line,str(e))
> kivy.lang.BuilderException:Parser:File"./scr.kv",line 74:
> ...
> 70:Button:
> 71: text:str(self.size)
> 72:Widget:
> >>73: size_hint:(None,Garbage)
> 74:
> 75:
> ...
> name 'Garbage'isnotdefined
> |
>
> Sorry, just a little hearted post about those small things that often
> escape our attention :)
>
> --
>
>


T500

unread,
Oct 31, 2012, 8:11:45 PM10/31/12
to kivy-...@googlegroups.com
LOLz

T500

unread,
Nov 1, 2012, 9:46:21 AM11/1/12
to kivy-...@googlegroups.com
But it is so much fun being one out. Never mind, a patch, it was a very tough assignment... I had forgotten how to generate a diff file :) 

In file: kivy/lang.py

class ParserException(Exception):
     
'''Exception raised when something wrong happened in a kv file.
     '''

@@ -483,12 +528,14 @@
         
self.filename = context.filename or '<inline>'
         
self.line = line
         sourcecode
= context.sourcecode
-        sc_start = max(0, line - 3)
+        sc_start = max(0, line - 2)
         sc_stop
= min(len(sourcecode), line + 3)
         sc
= ['...']
-        sc += ['   %4d:%s' % x for x in sourcecode[sc_start:line]]
-        sc += ['>> %4d:%s' % (line, sourcecode[line][1])]
-        sc += ['   %4d:%s' % x for x in sourcecode[line + 1:sc_stop]]
+        for x in range(sc_start, sc_stop):
+            if x == line:
+                sc += ['>> %4d:%s' % (line + 1, sourcecode[line][1])]
+            else:
+                sc += ['   %4d:%s' % (x + 1, sourcecode[x][1])]
         sc
+= ['...']
         sc
= '\n'.join(sc)


Test Example:
 kivy.lang.BuilderException: Parser: File "./scr.kv", line 60:
 
...
     
58:    id: canv
     
59:    Widget:
 
>>   60:        size: canv.size[0], of_kansas    
     
61:        Label:    
     
62:            id: title      
 
...
 name
'of_kansas' is not defined

Sorry, don't have not the foggiest how to do a git patch upload! 
(Do I hear a collective sigh of relief)

On Thursday, 1 November 2012 00:06:29 UTC, tshirtman wrote:
Reply all
Reply to author
Forward
0 new messages