Skip to content

bpo-45837: Properly deprecate turtle.RawTurtle.settiltangle #29618

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

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ Deprecated

(Contributed by Erlend E. Aasland in :issue:`5846`.)

* The :meth:`turtle.RawTurtle.settiltangle` is deprecated since Python 3.1,
it now emits a deprecation warning and will be removed in Python 3.13. Use
:meth:`turtle.RawTurtle.tiltangle` instead (it was earlier incorrectly marked
as deprecated, its docstring is now corrected).
(Contributed by Hugo van Kemenade in :issue:`45837`.)

Removed
=======
Expand Down
37 changes: 27 additions & 10 deletions Lib/turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import time
import inspect
import sys
import warnings

from os.path import isfile, split, join
from copy import deepcopy
Expand Down Expand Up @@ -2850,20 +2851,23 @@ def settiltangle(self, angle):
regardless of its current tilt-angle. DO NOT change the turtle's
heading (direction of movement).

Deprecated since Python 3.1

Examples (for a Turtle instance named turtle):
>>> turtle.shape("circle")
>>> turtle.shapesize(5,2)
>>> turtle.settiltangle(45)
>>> stamp()
>>> turtle.stamp()
>>> turtle.fd(50)
>>> turtle.settiltangle(-45)
>>> stamp()
>>> turtle.stamp()
>>> turtle.fd(50)
"""
tilt = -angle * self._degreesPerAU * self._angleOrient
tilt = math.radians(tilt) % math.tau
self.pen(resizemode="user", tilt=tilt)
warnings.warn("turtle.RawTurtle.settiltangle() is deprecated since "
"Python 3.1 and scheduled for removal in Python 3.13."
"Use tiltangle() instead.",
DeprecationWarning)
self.tiltangle(angle)

def tiltangle(self, angle=None):
"""Set or return the current tilt-angle.
Expand All @@ -2877,19 +2881,32 @@ def tiltangle(self, angle=None):
between the orientation of the turtleshape and the heading of the
turtle (its direction of movement).

Deprecated since Python 3.1
(Incorrectly marked as deprecated since Python 3.1, it is really
settiltangle that is deprecated.)

Examples (for a Turtle instance named turtle):
>>> turtle.shape("circle")
>>> turtle.shapesize(5,2)
>>> turtle.tilt(45)
>>> turtle.shapesize(5, 2)
>>> turtle.tiltangle()
0.0
>>> turtle.tiltangle(45)
>>> turtle.tiltangle()
45.0
>>> turtle.stamp()
>>> turtle.fd(50)
>>> turtle.tiltangle(-45)
>>> turtle.tiltangle()
315.0
>>> turtle.stamp()
>>> turtle.fd(50)
"""
if angle is None:
tilt = -math.degrees(self._tilt) * self._angleOrient
return (tilt / self._degreesPerAU) % self._fullcircle
else:
self.settiltangle(angle)
tilt = -angle * self._degreesPerAU * self._angleOrient
tilt = math.radians(tilt) % math.tau
self.pen(resizemode="user", tilt=tilt)

def tilt(self, angle):
"""Rotate the turtleshape by angle.
Expand All @@ -2908,7 +2925,7 @@ def tilt(self, angle):
>>> turtle.tilt(30)
>>> turtle.fd(50)
"""
self.settiltangle(angle + self.tiltangle())
self.tiltangle(angle + self.tiltangle())

def shapetransform(self, t11=None, t12=None, t21=None, t22=None):
"""Set or return the current transformation matrix of the turtle shape.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The :meth:`turtle.RawTurtle.settiltangle` is deprecated since Python 3.1,
it now emits a deprecation warning and will be removed in Python 3.13.

Use :meth:`turtle.RawTurtle.tiltangle` instead.

:meth:`turtle.RawTurtle.tiltangle` was earlier incorrectly marked as deprecated,
its docstring has been corrected.

Patch by Hugo van Kemenade.