-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
base: main
Are you sure you want to change the base?
Conversation
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
This reverts commit ebfa093.
…h a negative number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is user-facing, so please add a news entry. The easiest way will be with blurb-it, unless you already have blurb
installed locally.
Lib/turtle.py
Outdated
@@ -2141,7 +2141,10 @@ def pensize(self, width=None): | |||
""" | |||
if width is None: | |||
return self._pensize | |||
self.pen(pensize=width) | |||
elif width < 0: | |||
raise TurtleGraphicsError(f"width argument must be a positive number. It was {width}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not aware of the phrasing "it was [x]" in any other error messages. How about something like width must be a positive number, but got {width}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done it and blurb, as well.
Fix #133244.
Before
Now
For now, the
0
behaviour wasn't changed, but I think it would.If we call
turtle.pensize(0)
it changes the width to0
, but when the turtle draws, the real line's width is1
. It seems to be a misconception. However, change could be a backwards compatibility concern. Perhaps we can schedule a change for now with aDeprecationWarning
.