Skip to content

Commit

Permalink
Always set encoding when reading setup.cfg
Browse files Browse the repository at this point in the history
This should fix an issue on Window where the `setup.cfg` can contain
non-ascii characters, and Python is trying to use cp1252. This should be
safe as utf-8 is compatible with cp1252.

It's possible I'll eat my words and some other platform breaks with this
change, but let's try.

Closes #294.
  • Loading branch information
fsouza committed Mar 13, 2024
1 parent cce4c16 commit 67df301
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion autoflake.py
Expand Up @@ -20,6 +20,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Removes unused imports and unused variables as reported by pyflakes."""

from __future__ import annotations

import ast
Expand Down Expand Up @@ -1208,7 +1209,7 @@ def process_config_file(config_file_path: str) -> MutableMapping[str, Any] | Non
import configparser

reader = configparser.ConfigParser()
reader.read(config_file_path)
reader.read(config_file_path, encoding="utf-8")
if not reader.has_section("autoflake"):
return None

Expand Down

0 comments on commit 67df301

Please sign in to comment.