Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Encoding error

ID: py/encoding-errorKind: problemSecurity severity: Severity: errorPrecision: highTags:   - quality   - reliability   - correctnessQuery suites:   - python-security-and-quality.qls

Click to see the query in the CodeQL repository

Encoding errors prevent a module being evaluated and thus imported. An attempt to import a module with an invalid encoding will fail; aSyntaxError will be raised. Note that in Python 2, the default encoding is ASCII.

The existence of an encoding error in a module may suggest other problems as well. Either the module is never imported in practice and could be deleted or atry statement around the import is mistakenly discarding theSyntaxError.

Recommendation

Fixing the encoding error is the obvious fix. However, it is worth investigating why a module containing an encoding error was able to persist and address that problem as well.

If a different encoding should be used for the file, specify it explicitly by putting an encoding specification at the top of the file. For instance, to specify UTF-8 encoding, add the line#coding=utf-8.

References


[8]ページ先頭

©2009-2025 Movatter.jp