Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KV - TypeError on comment after canvas: #4415

Closed
KeyWeeUsr opened this issue Jun 19, 2016 · 5 comments
Closed

KV - TypeError on comment after canvas: #4415

KeyWeeUsr opened this issue Jun 19, 2016 · 5 comments
Labels
Component: KV-lang kivy/lang, factory

Comments

@KeyWeeUsr
Copy link
Contributor

When working with kv this jumps out if I place a comment(even with ##) after canvas:. It should appear even with .before/.after because it's the same block of code in parser.

<Something>:
    canvas: # error comment
        Color: # nothing
            rgba: 0, 0, 0, 0
        Rectangle: # nothing
            pos: self.pos
            size: self.size
 Traceback (most recent call last):
   File "C:\Users\...\main.py", line 341, in 
     My().run()
   File "C:\Users\...\Py27_11\lib\site-packages\kivy\app.py", line 801, in run
     self.load_kv(filename=self.kv_file)
   File "C:\Users\...\lib\site-packages\kivy\app.py", line 598, in load_kv
     root = Builder.load_file(rfilename)
   File "C:\Users\...\Py27_11\lib\site-packages\kivy\lang\builder.py", line 300, in l
oad_file
     return self.load_string(data, **kwargs)
   File "C:\Users\...\Py27_11\lib\site-packages\kivy\lang\builder.py", line 347, in l
oad_string
     parser = Parser(content=string, filename=fn)
   File "C:\Users\...\Py27_11\lib\site-packages\kivy\lang\parser.py", line 392, in __
init__
     self.parse(content)
   File "C:\Users\...\Py27_11\lib\site-packages\kivy\lang\parser.py", line 494, in pa
rse
     objects, remaining_lines = self.parse_level(0, lines)
   File "C:\Users\...\Py27_11\lib\site-packages\kivy\lang\parser.py", line 657, in pa
rse_level
     if current_property[:3] == 'on_':
 TypeError: 'NoneType' object has no attribute '__getitem__'
@dessant dessant added the Component: KV-lang kivy/lang, factory label Jun 29, 2016
@dessant dessant added this to the 2.0.0 milestone Jun 29, 2016
@saqib1707
Copy link
Contributor

@KeyWeeUsr This shows that one can put comments in a separate line and not at the end of a line.But first of all putting comments at the end of any line except canvas: or canvas.before(after) doesn't produces any error(which it should have) .
I think to remove all types of comments we can add a extra check like here.

@FluxIX
Copy link
Contributor

FluxIX commented Jan 18, 2017

If the parser used regular expressions on a line-level comments could appear at the end of lines.

@KeyWeeUsr
Copy link
Contributor Author

KeyWeeUsr commented Jan 18, 2017

Not at all. That part of the code handles all lines, while for this to work there has to be again introduced the same separation of blob: as kv element and <everything after :> as Python as for widgets, which would change the # error comment string to a comment and wouldn't raise an error.

with this check or with regex a single '#' in a property would trigger EOL error. This isn't really about removing the line in-place, it has to be done sooner/later.

@stale
Copy link

stale bot commented Oct 7, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 7, 2017
@dessant dessant removed the stale label May 13, 2018
@matham matham removed this from the 2.0.0 milestone Oct 28, 2020
@Julian-O
Copy link
Contributor

Julian-O commented Nov 7, 2023

Marking this a duplicate of #6657 (even though it is earlier).

@Julian-O Julian-O closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: KV-lang kivy/lang, factory
Projects
None yet
Development

No branches or pull requests

6 participants