Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46542
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <skip.montanaro@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; '(python': 0.07; 'revision': 0.07; 'file)': 0.09; 'python': 0.11; '2.7': 0.14; '%d,': 0.16; "%s'": 0.16; '23,': 0.16; 'expected,': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'lang': 0.16; 'stringio': 0.16; 'subject:between': 0.16; 'typeerror:': 0.16; 'unicode?': 0.16; 'sender:addr:gmail.com': 0.17; 'result.': 0.19; '>>>': 0.22; 'import': 0.22; 'print': 0.22; 'skip': 0.24; 'unicode': 0.24; 'tried': 0.27; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; '"",': 0.31; '13,': 0.31; 'python2.7': 0.31; 'file': 0.32; '(most': 0.33; 'older': 0.33; 'something': 0.35; 'received:google.com': 0.35; 'skip:" 50': 0.36; 'branch': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'system.': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'skip:t 30': 0.61; 'more': 0.64; 'default': 0.69; '12.1': 0.84; '2.7.': 0.84; 'subject:skip:S 10': 0.84; '2013,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=eWdgq22O2bS01dWRPvUMzApe+QJRR3J8SSUGtYuyrQA=; b=0V5wN6p+YGu4b/tVAVwPfg3gsYAAn9TyjtDF538wGlGVWibY/zKu0YcjREzCaQgClH 7CrAsoLGN1ial12umrOFclKD7iQEX1vLjqJHDiboONE5NJuxdVMzusAxc1bs6aTlcG3U AfQBhJaXOxpocy9czB1zxZuxeQlm3z4H5FaSaAkeMMow2QUp1BKpDwvHVw58zvkFYEm4 PlAbzZ9CTUx5Oy4xBBRAyCrPtaeNejwv6xaAMXVL6inSzUCAztnJvxprjO8nqjl7hMC0 f/g9yq/z1qUvHB0L0sOTTRybSAMYjcQookYhxvVxnJhja54ODJnMPsc4a8TDOa+gEoh3 XNag== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.112.137 with SMTP id iq9mr187784igb.94.1369946801561; Thu, 30 May 2013 13:46:41 -0700 (PDT) |
| Sender | skip.montanaro@gmail.com |
| Date | Thu, 30 May 2013 15:46:41 -0500 |
| X-Google-Sender-Auth | ICxWJL-L4zWkDZbbqMmisxh8fxc |
| Subject | Surprising difference between StringIO.StringIO and io.StringIO |
| From | Skip Montanaro <skip@pobox.com> |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2451.1369946809.3114.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369946809 news.xs4all.nl 15865 [2001:888:2000:d::a6]:51859 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:46542 |
Show key headers only | View raw
Consider this quick session (Python 2.7 using the tip of the 2.7
branch in Mercurial):
% python2.7
Python 2.7.5+ (2.7:93eb15779050, May 30 2013, 15:27:39)
[GCC 4.4.6 [TWW]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import traceback
>>>
>>> import StringIO
>>> s1 = StringIO.StringIO()
>>> traceback.print_stack(file=s1)
>>> print s1.getvalue()
File "<stdin>", line 1, in <module>
>>>
>>> import io
>>> s2 = io.StringIO()
>>> traceback.print_stack(file=s2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
269, in print_stack
print_list(extract_stack(f, limit), file)
File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
23, in print_list
' File "%s", line %d, in %s' % (filename,lineno,name))
File "/home/skipm/x86_64-linux3.1/lib/python2.7/traceback.py", line
13, in _print
file.write(str+terminator)
TypeError: unicode argument expected, got 'str'
>>> print s2.getvalue()
What is it about io.StringIO that it doesn't like strings and requires
Unicode? This is on an OpenSUSE 12.1 system. I have tried with LANG
set to the default ("en_US.UTF-8") and to "C". I also tried on a
Solaris system with an older micro revision of Python 2.7. Same
result.
Am I missing something about how io.StringIO works? I thought it was
a more-or-less drop-in replacement for StringIO.StringIO.
Thx,
Skip
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Surprising difference between StringIO.StringIO and io.StringIO Skip Montanaro <skip@pobox.com> - 2013-05-30 15:46 -0500
csiph-web