if isinstance(data, list):
data = tuple(data)
elif type_ == "image":
- if isinstance(data, str):
+ if isinstance(data, basestring):
if data.lower().endswith(".gif") and isfile(data):
data = TurtleScreen._image(data)
# else data assumed to be Photoimage
"""
if len(color) == 1:
color = color[0]
- if isinstance(color, str):
+ if isinstance(color, basestring):
if self._iscolorstring(color) or color == "":
return color
else:
def _cc(self, args):
"""Convert colortriples to hexstrings.
"""
- if isinstance(args, str):
+ if isinstance(args, basestring):
return args
try:
r, g, b = args
"""
#print "dot-1:", size, color
if not color:
- if isinstance(size, (str, tuple)):
+ if isinstance(size, (basestring, tuple)):
color = self._colorstr(size)
size = self._pensize + max(self._pensize, 4)
else:
down()
# some text
write("startstart", 1)
- write("start", 1)
+ write(u"start", 1)
color("red")
# staircase
for i in range(5):
tri = getturtle()
tri.resizemode("auto")
turtle = Turtle()
- turtle.resizemode("auto")
+ turtle.resizemode(u"auto")
turtle.shape("turtle")
turtle.reset()
turtle.left(90)
turtle.lt(30)
turtle.down()
turtle.speed(6)
- turtle.color("blue","orange")
+ turtle.color("blue",u"orange")
turtle.pensize(2)
tri.speed(6)
setheading(towards(turtle))
tri.stamp()
switchpen()
count += 1
- tri.write("CAUGHT! ", font=("Arial", 16, "bold"), align="right")
+ tri.write("CAUGHT! ", font=("Arial", 16, "bold"), align=u"right")
tri.pencolor("black")
- tri.pencolor("red")
+ tri.pencolor(u"red")
def baba(xdummy, ydummy):
clearscreen()
Library
-------
+- Issue #15618: Make turtle.py compatible with 'from __future__ import
+ unicode_literals'. Initial patch by Juancarlo Añez.
+
- Issue #20501: fileinput module no longer reads whole file into memory when using
fileinput.hook_encoded.
Based on patch by Stephen Tu.
- Issue #8478: Untokenizer.compat processes first token from iterator input.
- Patch based on lines from Georg Brandl, Eric Snow, and Gareth Rees.
+ Patch based on lines from Georg Brandl, Eric Snow, and Gareth Rees.
- Issue #20594: Avoid name clash with the libc function posix_close.