You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error on save in buffer_post_write - missing endif #452
I've isolated a piece of python code that will cause an error after doing :w on a62f8ab:
foo() = 1
The error:
[Pymode] Code checking is running ...
Error detected while processing function pymode#buffer_post_write..pymode#lint#check:
line 11:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/.../.vim/bundle/python-mode/pymode/lint.py", line 71, in code_check
env.run('g:PymodeLocList.current().extend', [e._info for e in errors])
File "/home/.../.vim/bundle/python-mode/pymode/environment.py", line 186, in run
self.prepare_value(a) for a in args
vim.error: Vim(call):E121: Undefined variable: null
Error detected while processing function pymode#buffer_post_write:
line 10:
E171: Missing :endif
I can't reproduce that error. However, putting foo() = 1 in one of my modules does cause this failure which makes more sense:
Run pyflakes {'builtins': '_'}
<traceback object at 0x101bd5fc8>
SyntaxError can't assign to function call (main.py, line 442)
What is slightly perplexing is that other types of syntax errors I introduced in my test module are detected and reported without causing an uncaught exception. Based on several other recently reported bugs that resulted in the linters throwing exceptions it might be a good idea to wrap the check_path() call in lint.py in a try block to catch and report unexpected exceptions.
E121: Undefined variable: null
E116: Invalid arguments for function 12
Traceback (most recent call last):
File "", line 1, in
File "/Users/.../.vim/bundle/python-mode/pymode/lint.py", line 71, in code_check
env.run('g:PymodeLocList.current().extend', [e._info for e in errors])
File "/Users/.../.vim/bundle/python-mode/pymode/environment.py", line 186, in run
self.prepare_value(a) for a in args
vim.error
This happens when I make a particular kind of error in using google's app engine entity queries:
If I have a model called MyModel with a property called value, in models.py, then writing a file containing the following causes this error:
sowingo/api/resources/office_inventory.py:290: keyword can't be an expression
office_inventory_lists_to_items.office_inventory_list_id = list_id
So the None column is there because PyFlakes gives no column. So...
env.run() calls env.prepare_args() on each of the arguments (in this case each e._info instance). This basically just runs json.dumps() on the value, and does some unicode cleanup if we're in on Python 2.x (but this part isn't blowing up). The actual error is vim.error: Vim(call):E121: Undefined variable: null. Since we're basically turning the arguments of env.run() into a :call command:
defrun(self, name, *args):
""" Run vim function. """vim.command('call %s(%s)'% (name, ", ".join([
self.prepare_value(a) forainargs
])))
I don't think that it likes the null column (since that's the only value that could end up as null that's being passed through).
There is probably a better way to deal with this (as the error report now says that the column is "1" which isn't true), but for those that want a quick patch this should work. Here's the patch:
diff --git a/pymode/lint.py b/pymode/lint.py
index 5053f7f..57fda6f 100644
--- a/pymode/lint.py+++ b/pymode/lint.py@@ -67,6 +67,16 @@ def code_check():
for e in errors:
e._info['bufnr'] = env.curbuf.number
+ if e._info['col'] is None:+ e._info['col'] = 1++ with open('/tmp/dump.txt', 'wb') as fh:+ import pprint+ for i, e in enumerate(errors):+ fh.write('ERROR[%d]._info = %s' % (+ i,+ pprint.pformat(e._info)+ ))
env.run('g:PymodeLocList.current().extend', [e._info for e in errors])
You can remove the error dump if you like, but it was useful for debugging.
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.
Activity
krader1961 commentedon Jul 11, 2014
I can't reproduce that error. However, putting
foo() = 1in one of my modules does cause this failure which makes more sense:What is slightly perplexing is that other types of syntax errors I introduced in my test module are detected and reported without causing an uncaught exception. Based on several other recently reported bugs that resulted in the linters throwing exceptions it might be a good idea to wrap the
check_path()call in lint.py in a try block to catch and report unexpected exceptions.aseyboldt commentedon Jul 25, 2014
I get the same error message on python code like this with version g2df674c
kirkboyer-wf commentedon Aug 25, 2014
I got nearly exact same Traceback as bgr:
E121: Undefined variable: null
E116: Invalid arguments for function 12
Traceback (most recent call last):
File "", line 1, in
File "/Users/.../.vim/bundle/python-mode/pymode/lint.py", line 71, in code_check
env.run('g:PymodeLocList.current().extend', [e._info for e in errors])
File "/Users/.../.vim/bundle/python-mode/pymode/environment.py", line 186, in run
self.prepare_value(a) for a in args
vim.error
This happens when I make a particular kind of error in using google's app engine entity queries:
If I have a model called MyModel with a property called value, in models.py, then writing a file containing the following causes this error:
import models
something = models.MyModel.query(models.MyModel.value=3)
(This code, correctly written, would have the line
something = models.MyModel.query(models.MyModel.value == 3)
)
bsandrow commentedon Oct 24, 2014
I will toss my +1 in with @kirkboyer-wf . I'm using SQLAlchemy, and I wrote a query as:
Rather than:
It caused this issue. I pulled the latest version of the develop branch (I use Vundle), but the issue is still present.
bsandrow commentedon Oct 24, 2014
More info:
It's blowing up on this line:
env.run()does some preparation on thee._infos that are passed through. Thee._infothat's blowing up in this case looks like:The output of
pyflakeslooks like:So the
Nonecolumn is there because PyFlakes gives no column. So...env.run()callsenv.prepare_args()on each of the arguments (in this case eache._infoinstance). This basically just runsjson.dumps()on the value, and does some unicode cleanup if we're in on Python 2.x (but this part isn't blowing up). The actual error isvim.error: Vim(call):E121: Undefined variable: null. Since we're basically turning the arguments ofenv.run()into a:callcommand:I don't think that it likes the
nullcolumn (since that's the only value that could end up asnullthat's being passed through).Patching it from:
to:
seems to do the trick (at least for now).
bsandrow commentedon Oct 24, 2014
There is probably a better way to deal with this (as the error report now says that the column is "1" which isn't true), but for those that want a quick patch this should work. Here's the patch:
You can remove the error dump if you like, but it was useful for debugging.
stale commentedon Feb 13, 2018
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 commentedon Mar 6, 2018
Closed due to inactivity.