Skip to content

Extraction error with tsg-python #19736

Open
@tvalenta

Description

@tvalenta

CodeQL is unable to extract and parse a Python3 file with the following line:

match["something"] = somethingelse

The CodeQL errors just reportsa syntax error and, logs aren't helpful.

A parse error occurred while processing <file> and as a result this file could not be analyzed. Check the syntax of the file using the python -m py\_compile command and correct any invalid syntax.

I've found that tsg-python throws an error for the word match when used in this syntax, but succeeds if the variable is renamed as xmatch

Failure - match

node 1
  _kind: "SyntaxErrorNode"
  _location: [0, 5, 0, 18]
  source: "[\"something\"]"

Success - xmatch

xmatch["something"] = somethingelse

Bumping the version of tree-sitter in the Python extractor seems to fix this.

tree-sitter = "=0.20.4"

I no longer get a syntax error when building with tree-sitter = "=0.20.10" which is the latest version that I could get to build the extractor. I'm not sure if the fix is this simple, and if tree-sitter-graph needs to also be bumped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PythonbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions