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

Issue with booleans in python3.8 #57

Closed
felixwoolford opened this issue Nov 19, 2019 · 5 comments
Closed

Issue with booleans in python3.8 #57

felixwoolford opened this issue Nov 19, 2019 · 5 comments

Comments

@felixwoolford
Copy link

felixwoolford commented Nov 19, 2019

Running neovim 0.4.3 and python 3.8, I am having an issue where semshi apparently stops working after trying to parse a True or False constant. This wasn't a problem with python 3.7. A simple example is:

class A:
    def __init__(self):
        self.a = 1
        self.b = True
        self.c = 2


The image below illustrates what happens when this is typed out, observe how 'self' is correctly italicized up until True, but is not italicized thereafter. And obviously the wonky highlighting on True itself.

semshi

The only highlighting which works thereafter is due to my python syntax config rather than semshi.

@felixwoolford
Copy link
Author

I believe this is the relevant error:

[ERROR @ handler.py:_update_loop:148] 86976 - Exception: Traceback (most recent call last):
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/handler.py", line 139, in _update_loop
   self._update_step(self._options.always_update_all_highlights)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/util.py", line 19, in wrapper
   res = func(*args, **kwargs)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/handler.py", line 159, in _update_step
   add, rem = self._parser.parse(code, force)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/util.py", line 19, in wrapper
   res = func(*args, **kwargs)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/parser.py", line 47, in parse
   return self._parse(*args, **kwargs)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/parser.py", line 68, in _parse
   new_nodes = self._make_nodes(code, new_lines, change_lineno)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/parser.py", line 108, in _make_nodes
   return visitor(lines, symtable_root, ast_root)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/util.py", line 19, in wrapper
   res = func(*args, **kwargs)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 46, in visitor
   visitor.visit(ast_root)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 122, in visit
   self._iter_node(node)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 397, in _iter_node
   self.visit(item)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 122, in visit
   self._iter_node(node)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 397, in _iter_node
   self.visit(item)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 112, in visit
   self._iter_node(node)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 397, in _iter_node
   self.visit(item)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 127, in visit
   self._iter_node(node)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 401, in _iter_node
   self.visit(value)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 127, in visit
   self._iter_node(node)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 401, in _iter_node
   self.visit(value)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 127, in visit
   self._iter_node(node)
 File "/home/felix/.local/share/nvim/plugged/semshi/rplugin/python3/semshi/visitor.py", line 388, in _iter_node
   for field in node._fields:
AttributeError: 'bool' object has no attribute '_fields'

@felixwoolford
Copy link
Author

felixwoolford commented Nov 19, 2019

I seem to have resolved this by changing line 400 in visitor.py to include bool (and also float which had the same problem) in the tuple:

elif value_type not in (str, int, bytes, bool, float):

I am not sure why this suddenly became an issue with 3.8 though! Does anyone have any idea what is going on here?

@numirias
Copy link
Owner

Going to look into proper 3.8 compatibility this weekend. Sorry for the trouble and thanks for your debugging efforts.

@numirias
Copy link
Owner

@felixwoolford Do you mind checking if the latest update works for you on 3.8?

@felixwoolford
Copy link
Author

Have just done a quick check so far but it seems to be working well. Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants