Skip to content

Dataloss when Unicode character cannot be mapped (with --overwrite-in-place and --lai) #2391

Open
@InstanceGaming

Description

@InstanceGaming

Version: 6.0.1
Interpreter: Python 3.11.2
OS: Windows 10 22H2 Build 19045.4894

Steps to reproduce

  1. Create a source file with exactly this content, for example orange.py:
import os

print('∅')
  1. Run isort --overwrite-in-place --lai 2 orange.py.
  2. Results in the file being emptied and the warning: ...isort\main.py:1214: UserWarning: Unable to parse file .\orange.py due to 'charmap' codec can't encode character '\u2205' in position 22: character maps to <undefined> sort_imports( # type: ignore.

What I expected

While I understand what the warning is about, I expect isort to not silently delete source code because of a simple encoding error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions