classification
Title: turtle.pencolor() chokes on unicode
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: apalala, terry.reedy
Priority: normal Keywords: patch

Created on 2012-08-10 16:03 by apalala, last changed 2012-08-10 18:11 by terry.reedy.

Files
File name Uploaded Description Edit
turtle_unicode.patch apalala, 2012-08-10 16:55 isninstance(x, basestring) instead of isinstance(x, str) review
Messages (3)
msg167883 - (view) Author: Juancarlo Añez (apalala) Date: 2012-08-10 16:03
>>> t.pencolor(u'red')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in pencolor
  File "/usr/lib/python2.7/lib-tk/turtle.py", line 2166, in pencolor
    color = self._colorstr(args)
  File "/usr/lib/python2.7/lib-tk/turtle.py", line 2600, in _colorstr
    return self.screen._colorstr(args)
  File "/usr/lib/python2.7/lib-tk/turtle.py", line 1111, in _colorstr
    r, g, b = [round(255.0*x) for x in (r, g, b)]
TypeError: can't multiply sequence by non-int of type 'float'
msg167893 - (view) Author: Juancarlo Añez (apalala) Date: 2012-08-10 16:55
This patch solves the problem by making turtle check for string against basestring insted of str.
msg167894 - (view) Author: Juancarlo Añez (apalala) Date: 2012-08-10 16:57
The bug showed up in a script that used:

from __future__ import unicode_literals
History
Date User Action Args
2012-08-10 18:11:49terry.reedysetnosy: + terry.reedy
2012-08-10 16:57:16apalalasetmessages: + msg167894
2012-08-10 16:55:59apalalasetfiles: + turtle_unicode.patch
keywords: + patch
messages: + msg167893
2012-08-10 16:03:19apalalacreate