Skip to content

Conversation

adorilson
Copy link
Contributor

@adorilson adorilson commented Jun 8, 2025

Fix #133244.

Before

>>> import turtle
>>> turtle.pensize(-1)
>>> turtle.forward(100)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 8, in forward
  File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 1636, in forward
    self._go(distance)
  File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 1597, in _go
    self._goto(ende)
  File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 3248, in _goto
    screen._drawline(self.drawingLineItem,
  File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 543, in _drawline
    self.cv.itemconfigure(lineitem, width=width)
  File "<string>", line 1, in itemconfigure
  File "/home/adorilson/anaconda3/lib/python3.12/tkinter/__init__.py", line 2988, in itemconfigure
    return self._configure(('itemconfigure', tagOrId), cnf, kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adorilson/anaconda3/lib/python3.12/tkinter/__init__.py", line 1712, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: bad screen distance "-1"

Now

>>> import turtle
>>> turtle.pensize(-1)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    turtle.pensize(-1)
    ~~~~~~~~~~~~~~^^^^
  File "<string>", line 8, in pensize
  File "/home/adorilson/workspace/cpython/Lib/turtle.py", line 2145, in pensize
    raise TurtleGraphicsError(f"width argument must be a positive number. It was {width}.")
turtle.TurtleGraphicsError: width argument must be a positive number. It was -1.

For now, the 0 behaviour wasn't changed, but I think it would.

If we call turtle.pensize(0) it changes the width to 0, but when the turtle draws, the real line's width is 1. It seems to be a misconception. However, change could be a backwards compatibility concern. Perhaps we can schedule a change for now with a DeprecationWarning.

vstinner and others added 5 commits June 7, 2025 12:29
…#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.
Copy link
Member

@ZeroIntensity ZeroIntensity left a 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.

@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make turtle.pensize smarter

3 participants