securesauce / precli

Precaution CLI
https://precli.readthedocs.io/
Other
7 stars 2 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 2: invalid start byte #472

Closed ericwb closed 1 month ago

ericwb commented 1 month ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/python/cpython
  2. precli --debug ../cpython/Lib/test/tokenizedata/badsyntax_pep3120.py
  3. See error
Working on file: ../cpython/Lib/test/tokenizedata/badsyntax_pep3120.py
Exception occurred when executing rules against ../cpython/Lib/test/tokenizedata/badsyntax_pep3120.py. Run "precli --debug ../cpython/Lib/test/tokenizedata/badsyntax_pep3120.py" to see the full traceback.
  Exception string: 'utf-8' codec can't decode byte 0xf6 in position 2: invalid start byte
  Exception traceback: Traceback (most recent call last):
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/core/run.py", line 141, in parse_file
    return parser.parse(artifact)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 111, in parse
    self.visit([tree.root_node])
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
    visitor_fn(node.children)
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 31, in visit_module
    self.visit(nodes)
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
    visitor_fn(node.children)
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
    visitor_fn(node.children)
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 177, in visit_call
    (func_call_args, func_call_kwargs) = self.get_func_args(nodes[1])
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 392, in get_func_args
    args.append(self.resolve(child, default=child))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 420, in resolve
    nodetext = node.utf8_text
               ^^^^^^^^^^^^^^
  File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 73, in utf8_text
    return self.text.decode()
           ^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 2: invalid start byte

Expected behavior No errors

Version

precli 0.5.4
Copyright 2024 Secure Saurce LLC
License BUSL-1.1: Business Source License 1.1 <https://spdx.org/licenses/BUSL-1.1.html>
  Python 3.12.2 (main, May 13 2024, 16:18:42) [Clang 15.0.0 (clang-1500.3.9.4)]

Additional context