Skip to content

fix astroid-error for parsing module encoding#7663

Merged
Pierre-Sassoulas merged 3 commits into
pylint-dev:mainfrom
clavedeluna:7661-encoding-crash
Oct 23, 2022
Merged

fix astroid-error for parsing module encoding#7663
Pierre-Sassoulas merged 3 commits into
pylint-dev:mainfrom
clavedeluna:7661-encoding-crash

Conversation

@clavedeluna
Copy link
Copy Markdown
Contributor

@clavedeluna clavedeluna commented Oct 22, 2022

Type of Changes

Type
🐛 Bug fix

Description

Fix dict operation bug when parsing module to determine module encoding. Also added tests not previously added when handling this issue in #7097

Closes #7661

if not encoding.startswith("utf"):
if encoding not in UNICODE_BOMS:
return encoded
bom = UNICODE_BOMS[encoding]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since all UNICODE_BOMS are utf..., it's redundant to check if it starts with utf. Just checking if encoding is in UNICODE is sufficient and prevents unsafe KeyError

@coveralls
Copy link
Copy Markdown

coveralls commented Oct 22, 2022

Pull Request Test Coverage Report for Build 3307142525

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.358%

Totals Coverage Status
Change from base Build 3304001707: 0.0%
Covered Lines: 17172
Relevant Lines: 18008

💛 - Coveralls

@github-actions

This comment has been minimized.

@Pierre-Sassoulas Pierre-Sassoulas added Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer Crash 💥 A bug that makes pylint crash labels Oct 22, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.6 milestone Oct 22, 2022
Copy link
Copy Markdown
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you !

Comment thread doc/whatsnew/fragments/7661.bugfix Outdated
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@github-actions

This comment has been minimized.

Comment thread doc/whatsnew/fragments/7661.bugfix Outdated
@github-actions
Copy link
Copy Markdown
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 416bc99

@Pierre-Sassoulas Pierre-Sassoulas merged commit 096f6d7 into pylint-dev:main Oct 23, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Backported and removed Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer labels Nov 16, 2022
Pierre-Sassoulas added a commit that referenced this pull request Nov 16, 2022
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Pierre-Sassoulas added a commit that referenced this pull request Nov 17, 2022
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported Crash 💥 A bug that makes pylint crash

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when illegal file encoding utf in the first line

3 participants