Skip to content

Commit c94664c

Browse files
authored
bpo-45837: Properly deprecate turtle.RawTurtle.settiltangle (GH-29618)
1 parent e4bb22f commit c94664c

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

Doc/whatsnew/3.11.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ Deprecated
369369

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

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

373378
Removed
374379
=======

Lib/turtle.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
import time
111111
import inspect
112112
import sys
113+
import warnings
113114

114115
from os.path import isfile, split, join
115116
from copy import deepcopy
@@ -2850,20 +2851,23 @@ def settiltangle(self, angle):
28502851
regardless of its current tilt-angle. DO NOT change the turtle's
28512852
heading (direction of movement).
28522853
2854+
Deprecated since Python 3.1
28532855
28542856
Examples (for a Turtle instance named turtle):
28552857
>>> turtle.shape("circle")
28562858
>>> turtle.shapesize(5,2)
28572859
>>> turtle.settiltangle(45)
2858-
>>> stamp()
2860+
>>> turtle.stamp()
28592861
>>> turtle.fd(50)
28602862
>>> turtle.settiltangle(-45)
2861-
>>> stamp()
2863+
>>> turtle.stamp()
28622864
>>> turtle.fd(50)
28632865
"""
2864-
tilt = -angle * self._degreesPerAU * self._angleOrient
2865-
tilt = math.radians(tilt) % math.tau
2866-
self.pen(resizemode="user", tilt=tilt)
2866+
warnings.warn("turtle.RawTurtle.settiltangle() is deprecated since "
2867+
"Python 3.1 and scheduled for removal in Python 3.13."
2868+
"Use tiltangle() instead.",
2869+
DeprecationWarning)
2870+
self.tiltangle(angle)
28672871

28682872
def tiltangle(self, angle=None):
28692873
"""Set or return the current tilt-angle.
@@ -2877,19 +2881,32 @@ def tiltangle(self, angle=None):
28772881
between the orientation of the turtleshape and the heading of the
28782882
turtle (its direction of movement).
28792883
2880-
Deprecated since Python 3.1
2884+
(Incorrectly marked as deprecated since Python 3.1, it is really
2885+
settiltangle that is deprecated.)
28812886
28822887
Examples (for a Turtle instance named turtle):
28832888
>>> turtle.shape("circle")
2884-
>>> turtle.shapesize(5,2)
2885-
>>> turtle.tilt(45)
2889+
>>> turtle.shapesize(5, 2)
2890+
>>> turtle.tiltangle()
2891+
0.0
2892+
>>> turtle.tiltangle(45)
2893+
>>> turtle.tiltangle()
2894+
45.0
2895+
>>> turtle.stamp()
2896+
>>> turtle.fd(50)
2897+
>>> turtle.tiltangle(-45)
28862898
>>> turtle.tiltangle()
2899+
315.0
2900+
>>> turtle.stamp()
2901+
>>> turtle.fd(50)
28872902
"""
28882903
if angle is None:
28892904
tilt = -math.degrees(self._tilt) * self._angleOrient
28902905
return (tilt / self._degreesPerAU) % self._fullcircle
28912906
else:
2892-
self.settiltangle(angle)
2907+
tilt = -angle * self._degreesPerAU * self._angleOrient
2908+
tilt = math.radians(tilt) % math.tau
2909+
self.pen(resizemode="user", tilt=tilt)
28932910

28942911
def tilt(self, angle):
28952912
"""Rotate the turtleshape by angle.
@@ -2908,7 +2925,7 @@ def tilt(self, angle):
29082925
>>> turtle.tilt(30)
29092926
>>> turtle.fd(50)
29102927
"""
2911-
self.settiltangle(angle + self.tiltangle())
2928+
self.tiltangle(angle + self.tiltangle())
29122929

29132930
def shapetransform(self, t11=None, t12=None, t21=None, t22=None):
29142931
"""Set or return the current transformation matrix of the turtle shape.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The :meth:`turtle.RawTurtle.settiltangle` is deprecated since Python 3.1,
2+
it now emits a deprecation warning and will be removed in Python 3.13.
3+
4+
Use :meth:`turtle.RawTurtle.tiltangle` instead.
5+
6+
:meth:`turtle.RawTurtle.tiltangle` was earlier incorrectly marked as deprecated,
7+
its docstring has been corrected.
8+
9+
Patch by Hugo van Kemenade.

0 commit comments

Comments
 (0)