8000 gh-133244: TPen.pensize raises TurtleGraphicsError if called with a negative number by adorilson · Pull Request #135268 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-133244: TPen.pensize raises TurtleGraphicsError if called with a negative number #135268

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
gh-133244: Replace 'it was' by 'but got' in error message
  • Loading branch information
adorilson committed Jun 9, 2025
commit f021b16747644a1b4673dc81fa833c3a79e84aa7
2 changes: 1 addition & 1 deletion Lib/test/test_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def test_pensize_with_nonpositive_numbers(self):
self.assertEqual(0, tpen.pensize())

width = -1
msg = f"width argument must be a positive number. It was {width}."
msg = f"width argument must be a positive number, but got {width}."
with self.assertRaisesRegex(turtle.TurtleGraphicsError, re.escape(msg)):
tpen.pensize(width)

Expand Down
3 changes: 2 additions & 1 deletion Lib/turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,8 @@ def pensize(self, width=None):
if width is None:
return self._pensize
elif width < 0:
raise TurtleGraphicsError(f"width argument must be a positive number. It was {width}.")
msg = f"width argument must be a positive number, but got {width}."
raise TurtleGraphicsError(msg)
else:
self.pen(pensize=width)

Expand Down
Loading
0