This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author exarkun
Recipients exarkun
Date 2008-12-10.13:19:04
SpamBayes Score 1.1909682e-08
Marked as misclassified No
Message-id <1228915146.01.0.235938679842.issue4618@psf.upfronthosting.co.za>
In-reply-to
Content
Consider:

exarkun@charm:~$ ~/Projects/python/branches/release26-maint/python 
Python 2.6+ (trunk:66997, Oct 23 2008, 16:02:09) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(o):
...     print type(o)
... 
>>> f('foo')
<type 'str'>
>>> from __future__ import unicode_literals
>>> f('foo')
<type 'unicode'>
>>> from __future__ import print_function
>>> print('foo')
foo
>>> from io import StringIO
>>> print('foo', file=StringIO())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/exarkun/Projects/python/branches/release26-maint/Lib/io.py", line
1487, in write
    s.__class__.__name__)
TypeError: can't write str to text stream
>>> StringIO().write('foo')
3
>>> StringIO().write(b'foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/exarkun/Projects/python/branches/release26-maint/Lib/io.py", line
1487, in write
    s.__class__.__name__)
TypeError: can't write str to text stream
>>>

It seems the type of a literal string is `str´ when it is an argument to
the print function, even with the unicode_literals future import in effect.
History
Date User Action Args
2008-12-10 13:19:06exarkunsetrecipients: + exarkun
2008-12-10 13:19:06exarkunsetmessageid: <1228915146.01.0.235938679842.issue4618@psf.upfronthosting.co.za>
2008-12-10 13:19:05exarkunlinkissue4618 messages
2008-12-10 13:19:04exarkuncreate