Skip to content

[Bug] TypeError: 'bool' object is not iterable #11

Open

Description

@Kristinita

1. Summary

I can not begin to use BoundKeys, I get stack trace.

2. Expected behavior

BoundKeys

3. Actual behavior

command: bound_keys
Error parsing JSON: Expecting property name enclosed in double quotes: line 373 column 13 (char 11616)
Error parsing JSON: Expecting property name enclosed in double quotes: line 7 column 2 (char 126)
Error parsing JSON: Expecting property name enclosed in double quotes: line 8 column 11 (char 211)
Traceback (most recent call last):
  File "E:\Sublime Text 3\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "boundkeys in E:\Sublime Text 3\Data\Installed Packages\BoundKeys.sublime-package", line 356, in run
TypeError: 'bool' object is not iterable

4. Steps to reproduce

The problem is reproduced for me in a version of Sublime Text without plugins and user settings.

I install BoundKeys via Package Control → I restart Sublime Text → Ctrl+Shift+P → List bound keys → I get stack trace.

All my .sublime-keymap files successfully worked for me.

5. Environment

Operating system and version:
Windows 32-bit 10.0.14393
Sublime Text:
Build 3126

Thanks.

Activity

  1. mg979 commented on Apr 14, 2017

    @mg979

    Possible fix, insert at line 43:

            # other trailing commas
            fixTrailing = re.compile("%s\s+%s" % (
                re.escape(','),
                re.escape("}")
            ), re.MULTILINE)
            data = re.sub(fixTrailing, "}", data)
    
  2. Kristinita commented on Apr 15, 2017

    @Kristinita
    Author

    @mg979 , I paste it right?

                # Build 3021 & 3033 have trailing commas in the default files
                fixTrailing = re.compile("%s\s+%s" % (
                    re.escape("},"),
                    re.escape("]")
                ), re.MULTILINE)
                data = re.sub(fixTrailing, "}   ]", data)
    
                # other trailing commas
                fixTrailing = re.compile("%s\s+%s" % (
                    re.escape(','),
                    re.escape("}")
                ), re.MULTILINE)
                data = re.sub(fixTrailing, "}", data)
    
                return json.loads(data, strict=False)

    It doesn't work for me, I get the same error.

    Thanks.

  3. mg979 commented on Apr 15, 2017

    @mg979

    In my installation it works. I also had to do this.
    Maybe you have something else yet that causes an error. What does the console say exactly?

  4. dpc00 commented on Oct 22, 2026

    @dpc00

    Claude reports:

    I get the same TypeError: 'bool' object is not iterable on Sublime Text build 4215 (Windows 11, BoundKeys from Package Control). Console:

    Error parsing JSON: Illegal trailing comma before end of object: line 59 column 4 (char 2977)
    Error parsing JSON: Illegal trailing comma before end of object: line 6 column 71 (char 173)
    Error parsing JSON: Illegal trailing comma before end of object: line 150 column 10 (char 6962)
    Traceback ...
      File ".../boundkeys.py", line 356, in run
        for binding in userKeys[lastPath]["object"]:
    TypeError: 'bool' object is not iterable
    

    Cause: jsonify() returns False when a keymap does not parse (the strict json.loads rejects trailing commas inside objects, which Sublime Text's own parser accepts; the workaround only handles }, followed by ]). The zip branch (lines 301-307) stores that False as "object", and the loops at lines 349-359 then iterate over it.

    Tested fix in a local copy: in jsonify() use return sublime.decode_value(data) (accepts comments and trailing commas like Sublime itself), and in the two loops test if subKeys[lastPath].get("object"): / if userKeys[lastPath].get("object"): instead of if "object" in .... With that the command no longer raises. (The results tab was then empty, a separate problem, filed separately.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions