JulianEberius/SublimePython — pull request #3 by coaxmetal (2013-04-02 18:49:10+00:00)
Title: Safety checks and fixes

I noticed several instances in the sublime console where SublimePython produced an AttributeError (in syntax checking and __getattr__). I added some simple checks/fixes for these issues, though I haven't written any tests. It naively seems to have worked though.

here are some snippets from the sublime console of the errrors I was addressing:

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 508, in run_
return self.run()
File "/Users/dbl/Library/Application Support/Sublime Text 3/Installed Packages/SublimePython.sublime-package/sublime_python.py", line 162, in run
TypeError: 'Proxy' object does not support item deletion
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 310, in on_activated_async
callback.on_activated_async(v)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Installed Packages/SublimePython.sublime-package/sublime_python.py", line 181, in on_activated_async
self._check(view)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Installed Packages/SublimePython.sublime-package/sublime_python.py", line 216, in _check
view.substr(sublime.Region(0, view.size())))
File "/Users/dbl/Library/Application Support/Sublime Text 3/Installed Packages/SublimePython.sublime-package/sublime_python.py", line 92, in wrapper
method = getattr(self.proxy, attr)
AttributeError: 'NoneType' object has no attribute 'check_syntax'

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 262, in on_post_save_async
callback.on_post_save_async(v)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Installed Packages/SublimePython.sublime-package/sublime_python.py", line 297, in on_post_save_async
proxy.report_changed(root_folder_for(view), path)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Installed Packages/SublimePython.sublime-package/sublime_python.py", line 92, in wrapper
method = getattr(self.proxy, attr)
AttributeError: 'NoneType' object has no attribute 'report_changed'

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 214, in on_load_async
callback.on_load_async(v)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Packages/SublimePython/sublime_python.py", line 175, in on_load_async
self._check(view)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Packages/SublimePython/sublime_python.py", line 228, in _check
self.on_selection_modified_async(view)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Packages/SublimePython/sublime_python.py", line 190, in on_selection_modified_async
if (not 'Python' in view.settings().get('syntax')
TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 310, in on_activated_async
callback.on_activated_async(v)
File "/Users/dbl/Library/Application Support/Sublime Text 3/Packages/SublimePython/sublime_python.py", line 179, in on_activated_async
if not 'Python' in view.settings().get('syntax') or view.is_scratch():
TypeError: argument of type 'NoneType' is not iterable