Repository navigation
Add StringIO newline tracking #8539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,9 +69,25 @@ def test_05(): | |||||||||||||||||||||
| assert f.readline() == "" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def test_06(): | ||||||||||||||||||||||
| f = StringIO(newline=None) | ||||||||||||||||||||||
| f.write("\r") | ||||||||||||||||||||||
| f.__init__("x\n", newline=None) | ||||||||||||||||||||||
| assert f.newlines == "\n" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| f.close() | ||||||||||||||||||||||
| try: | ||||||||||||||||||||||
| f.newlines | ||||||||||||||||||||||
| except ValueError: | ||||||||||||||||||||||
| pass | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| assert False | ||||||||||||||||||||||
|
Comment on lines
+80
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep the closed-stream failure path active under optimization. Ruff reports B018 for the bare property access on Line 80 and B011 for Proposed lint-safe change- f.newlines
+ _ = f.newlines
...
- assert False
+ raise AssertionError("newlines access did not fail on a closed stream")📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.16.1)[warning] 80-80: Found useless expression. Either assign it to a variable or remove it. (B018) [warning] 84-84: Do not Replace (B011) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||
| test_01() | ||||||||||||||||||||||
| test_02() | ||||||||||||||||||||||
| test_03() | ||||||||||||||||||||||
| test_04() | ||||||||||||||||||||||
| test_05() | ||||||||||||||||||||||
| test_06() | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.