SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

TypeError: argument of type 'NoneType' is not iterable #129

Closed evandrocoan closed 7 years ago

evandrocoan commented 7 years ago

This showed up when I opened a project:

Traceback (most recent call last):
  File "D:\SublimeText\Data\Packages\PackageDev\plugins_\settings\__init__.py", line 174, in do_linting
    and USER_PATH in self.view.file_name()
TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "D:\SublimeText\Data\Packages\PackageDev\plugins_\settings\__init__.py", line 174, in do_linting
    and USER_PATH in self.view.file_name()
TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "D:\SublimeText\sublime_plugin.py", line 513, in on_selection_modified_async
    callback.on_selection_modified_async(v)
  File "D:\SublimeText\Data\Packages\SublimeLinter\sublimelinter.py", line 394, in on_selection_modified_async
    view = self.get_focused_view_id(view)
  File "D:\SublimeText\Data\Packages\SublimeLinter\sublimelinter.py", line 384, in get_focused_view_id
    for view in view.window().views():
AttributeError: 'NoneType' object has no attribute 'views'
Finished normally

Environment

  1. https://github.com/SublimeText/PackageDev/blob/242361d2b837bb4b61fc2f2b49c2199bc030451e/plugins_/settings/__init__.py#L174-L180
FichteFoll commented 7 years ago

Interesting. In theory, this exception shouldn't be possible because self.known_settings is only set in the class's __init__:

https://github.com/SublimeText/PackageDev/blob/a5adaa2a4344b80bbb98324931d9a8354f9a737f/plugins_/settings/__init__.py#L79-L85

And if view.file_name() is None there, self.known_settings is also None, in which case the conditional in line 171 should exit before reaching self.view.file_name():

https://github.com/SublimeText/PackageDev/blob/a5adaa2a4344b80bbb98324931d9a8354f9a737f/plugins_/settings/__init__.py#L171-L176

To my knowledge, it's not possible to have a view that previously had a file name return None later.

It would be nice if you could reproduce this with a debug log.

evandrocoan commented 7 years ago

I just enabled debug mode, when I notice it again I will post it here.

evandrocoan commented 7 years ago

I got these when I open/close a settings file:

reloading /D/User/Dropbox/Applications/SoftwareVersioning/SublimeText/Data/Packages/SyntaxManager/Main.sublime-menu
[PackageDev.plugins_.settings] DEBUG: initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\AlignTab\\AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings:initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\AlignTab\\AlignTab.sublime-settings'
[PackageDev.plugins_.settings] DEBUG: initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\User\\AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings:initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\User\\AlignTab.sublime-settings'
[PackageDev.plugins_.settings.known_settings] DEBUG: cache hit 'AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings.known_settings:cache hit 'AlignTab.sublime-settings'
Unable to open /D/User/Dropbox/Applications/SoftwareVersioning/SublimeText/Data/Packages/User/AlignTab.sublime-settings
[PackageDev.plugins_.settings.known_settings] DEBUG: loading defaults and comments for 'AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings.known_settings:loading defaults and comments for 'AlignTab.sublime-settings'
[PackageDev.plugins_.settings.known_settings] DEBUG: found 1 'AlignTab.sublime-settings' files
DEBUG:PackageDev.plugins_.settings.known_settings:found 1 'AlignTab.sublime-settings' files
[PackageDev.plugins_.settings.known_settings] DEBUG: parsing 'Packages/AlignTab/AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings.known_settings:parsing 'Packages/AlignTab/AlignTab.sublime-settings'
[PackageDev.plugins_.settings.known_settings] DEBUG: loading took 0.166s
DEBUG:PackageDev.plugins_.settings.known_settings:loading took 0.166s
[PackageDev.plugins_.settings] DEBUG: deleting SettingsListener instance for 'D:\\SublimeText\\Data\\Packages\\AlignTab\\AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings:deleting SettingsListener instance for 'D:\\SublimeText\\Data\\Packages\\AlignTab\\AlignTab.sublime-settings'
[PackageDev.plugins_.settings] DEBUG: initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\AlignTab\\AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings:initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\AlignTab\\AlignTab.sublime-settings'
[PackageDev.plugins_.settings.known_settings] DEBUG: cache hit 'AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings.known_settings:cache hit 'AlignTab.sublime-settings'
[PackageDev.plugins_.settings] DEBUG: deleting SettingsListener instance for 'D:\\SublimeText\\Data\\Packages\\User\\AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings:deleting SettingsListener instance for 'D:\\SublimeText\\Data\\Packages\\User\\AlignTab.sublime-settings'
[PackageDev.plugins_.settings] DEBUG: initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\User\\AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings:initializing SettingsListener for 'D:\\SublimeText\\Data\\Packages\\User\\AlignTab.sublime-settings'
[PackageDev.plugins_.settings.known_settings] DEBUG: cache hit 'AlignTab.sublime-settings'
DEBUG:PackageDev.plugins_.settings.known_settings:cache hit 'AlignTab.sublime-settings'
Traceback (most recent call last):
  File "D:\SublimeText\Data\Packages\PackageDev\plugins_\settings\__init__.py", line 174, in do_linting
    command, argument = href.split(":")
TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "D:\SublimeText\Data\Packages\PackageDev\plugins_\settings\__init__.py", line 174, in do_linting
    command, argument = href.split(":")
TypeError: argument of type 'NoneType' is not iterable
evandrocoan commented 7 years ago

This seems to be fixed with the latest updates on the master branch. https://github.com/evandrocoan/PackageDev/pull/3