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 jmfauth
Recipients jmfauth
Date 2010-06-04.09:05:55
SpamBayes Score 0.0002975119
Marked as misclassified No
Message-id <1275642358.27.0.48977523408.issue8895@psf.upfronthosting.co.za>
In-reply-to
Content
I was confused about the newline argument/attribute
in the misc. classes of the io module until I realize
there is a spelling issue between the docs and the
real implementation. (Py 2.6.5, Py2.7b2). Py 3.x not
tested.

>>> sys.version
2.7b2 (r27b2:81019, May  9 2010, 11:33:14) [MSC v.1500 32 bit (Intel)]
>>> sio = io.StringIO(u'abc')
>>> sio.encoding, type(sio.encoding)
(None, <type 'NoneType'>)
>>> sio.errors, type(sio.errors)
(None, <type 'NoneType'>)
>>> sio.newline, type(sio.newline)
Traceback (most recent call last):
  File "<psi last command>", line 1, in <module>
AttributeError: '_io.StringIO' object has no attribute 'newline'
>>> sio.newlines, type(sio.newlines)
(None, <type 'NoneType'>)
>>> 


>>> tio = io.TextIOWrapper(io.BytesIO())
>>> tio.buffer, type(tio.buffer)
(<_io.BytesIO object at 0x02E6E600>, <type '_io.BytesIO'>)
>>> tio.encoding, type(tio.encoding)
('cp1252', <type 'str'>)
>>> tio.errors, type(tio.errors)
('strict', <type 'str'>)
>>> tio.line_buffering, type(tio.line_buffering)
(False, <type 'bool'>)
>>> tio.newline, type(tio.newline)
Traceback (most recent call last):
  File "<psi last command>", line 1, in <module>
AttributeError: '_io.TextIOWrapper' object has no attribute 'newline'
>>> tio.newlines, type(tio.newlines)
(None, <type 'NoneType'>)

>>> sys.version
2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
>>> import io
>>> tio = io.TextIOWrapper(io.BytesIO())
>>> tio.encoding, type(tio.encoding)
('cp1252', <type 'str'>)
>>> tio.line_buffering, type(tio.line_buffering)
(False, <type 'bool'>)
>>> tio.errors, type(tio.errors)
(u'strict', <type 'unicode'>)
>>> tio.newline, type(tio.newline)
Traceback (most recent call last):
  File "<psi last command>", line 1, in <module>
AttributeError: 'TextIOWrapper' object has no attribute 'newline'
>>> tio.newlines, type(tio.newlines)
(None, <type 'NoneType'>)
>>> [e for e in dir(tio) if 'new' in e]
['__new__', 'newlines']
>>>
History
Date User Action Args
2010-06-04 09:05:58jmfauthsetrecipients: + jmfauth
2010-06-04 09:05:58jmfauthsetmessageid: <1275642358.27.0.48977523408.issue8895@psf.upfronthosting.co.za>
2010-06-04 09:05:56jmfauthlinkissue8895 messages
2010-06-04 09:05:55jmfauthcreate