Terry J. Reedy added the comment: The particular error message is an artifact of 'red' having 3 letters, so that r,g,b = 'red' 'works'. turtle.pencolor(u'blue') raises turtle.TurtleGraphicsError: bad color arguments: blue.
In general, 'solves the problem' is a bit vague. In this case, it should mean 'make the exception go away and actually actually changes the pencolor', which the patch does. Chunk 2 patches ._colorstr. Once a unicode passes the revised test, the subsequent line if self._iscolorstring(color) or color == "": works because a) ._iscolorstring calls into tk, which is unicode based, and b) in 2.x, the comparison u''=='' is True. To be applied, test/test_turtle.py would need to have one or more tests added. Chunks 2, 3, and 4 should fix all color issues. Chunk 1 is about file names instead. Though not stated, the intent appears to be to fix all possible issues with unicode_literals, as should be done if any are. (I did verify that there are no other isinstance(x, str) checks.) In particular, chunk 1 needs a test. Does if data.lower().endswith(".gif") and isfile(data): data = TurtleScreen._image(data) work when data is unicode? The unicode==str comparison works. Does os.path.isfile(unicode) work? The os.path doc does not specify 'path', but unicode seems to work. TurtleScreen._image returns return TK.PhotoImage(file=filename) I have not found any doc on whether the file option on 2.7 widgets can be unicode or not. I asked on pydev about the generic issue of a 2.7 param being documented as a 'string' and the __future__ import changing str to unicode in thread 'unicode_string future, str -> basestring, fix or feature'. ---------- stage: -> patch review _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15618> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com