SublimeText / AdvancedNewFile

File creation plugin for Sublime Text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: super(type, obj): obj must be an instance or subtype of type

evandrocoan opened this issue · comments

It just popped on the Sublime Text console after activating the plugin:

Traceback (most recent call last):
  File "D:\SublimeText\sublime_plugin.py", line 191, in create_window_commands
    cmds.append(class_(window))
  File "D:\SublimeText\Data\Packages\AdvancedNewFile\advanced_new_file\commands\copy_file_command.py", line 11, in __init__
    super(AdvancedNewFileCopy, self).__init__(window)
TypeError: super(type, obj): obj must be an instance or subtype of type

These lines are:

File: Packages/AdvancedNewFile/advanced_new_file/commands/copy_file_command.py
 9: class AdvancedNewFileCopy(DuplicateFileBase):
10:     def __init__(self, window):
11:         super(AdvancedNewFileCopy, self).__init__(window)

Now after restarting Sublime Text and using some command of this package I got this other error:

Traceback (most recent call last):
  File "D:\Data\Packages\AdvancedNewFile\advanced_new_file\commands\command_base.py", line 297, in __update_filename_input
    base, path = self.split_path(path_in)
  File "D:\Data\Packages\AdvancedNewFile\advanced_new_file\commands\command_base.py", line 174, in split_path
    root, path_offset = self.platform.parse_nix_path(root, path)
  File "D:\Data\Packages\AdvancedNewFile\advanced_new_file\platform\windows_platform.py", line 26, in parse_nix_path
    root, _ = os.path.splitdrive(self.view.file_name())
  File "./python3.3/ntpath.py", line 162, in splitdrive
TypeError: object of type 'NoneType' has no len()

I use Sublime Text build 3141, Windows 10.

Related issues:

  1. #115 obj must be an instance or subtype of type
  2. #134 TypeError: super(type, obj): obj must be an instance or subtype of type
  3. #78 TypeError: super(type, obj): obj must be an instance or subtype of type

This happens because when Sublime Text uses imp.reload_module, the internal class ids of the classes changes, causing all super(ClassName, self) calls to fails.

  1. getsentry/raven-python#144 super(type, obj): obj must be an instance or subtype of type

This happens because Python 3.3 built-in imp.reload module is bugged. The solution would be use something else other than imp.reload you use in places like this:
https://github.com/skuroda/Sublime-AdvancedNewFile/blob/416d26cc49cf78c5143e6535520f67c3340569d9/advanced_new_file/reloader.py#L13-L16

The newer versions as Python 3.4 the imp module was deprecated.