File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
crates/ruff_linter/src/rules/pylint/rules Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,17 @@ use crate::fix::edits::add_argument;
2828/// Python 3.10 and later, or `locale.getpreferredencoding()` on earlier versions,
2929/// to make the encoding explicit.
3030///
31+ /// ## Fix safety
32+ /// This fix is always unsafe and may change the program's behavior. It forces
33+ /// `encoding="utf-8"` as the default, regardless of the platform’s actual default
34+ /// encoding, which may cause `UnicodeDecodeError` on non-UTF-8 systems.
35+ /// ```python
36+ /// with open("test.txt") as f:
37+ /// print(f.read()) # before fix (on UTF-8 systems): 你好,世界!
38+ /// with open("test.txt", encoding="utf-8") as f:
39+ /// print(f.read()) # after fix (on Windows): UnicodeDecodeError
40+ /// ```
41+ ///
3142/// ## Example
3243/// ```python
3344/// open("file.txt")
You can’t perform that action at this time.
0 commit comments