[issue27154] Regression in file.writelines behavior

2020-07-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Removing 'b' and 'u', writelines([s]) and write(s) both now read as s.

--
nosy: +terry.reedy
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2020-06-28 Thread Zackery Spytz


Zackery Spytz  added the comment:

Python 2 is EOL, so I think this issue should be closed.

--
nosy: +ZackerySpytz

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2018-09-23 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2016-05-29 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2016-05-29 Thread R. David Murray

R. David Murray added the comment:

Thanks.

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2016-05-29 Thread Alexey Borzenkov

Alexey Borzenkov added the comment:

Didn't need to bisect, it's very easy to find the problematic commit, since 
writelines doesn't change that often:

https://hg.python.org/releases/2.7.11/rev/db842f730432

The old code was buggy in a sense that it always called PyObject_AsCharBuffer 
due to the way the condition is structured, but this bugginess was what allowed 
it to work correctly with unicode objects. After the commit unicode objects are 
treated like any other buffer, and that's why internal UCS2 or UCS4 
representation gets written to the file.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2016-05-29 Thread R. David Murray

R. David Murray added the comment:

Any chance you could bisect to figure out which changeset caused the problem?  
I'm surprised that something like this would happen, we aren't in general 
making changes at that level to python2 any more.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2016-05-29 Thread Марк Коренберг

Changes by Марк Коренберг :


--
nosy: +mmarkk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27154] Regression in file.writelines behavior

2016-05-29 Thread Alexey Borzenkov

New submission from Alexey Borzenkov:

There's a regression in file.writelines behavior for binary files when writing 
unicode strings, which seems to have first appeared in Python 2.7.7. The 
problem is that when writing unicode strings the internal representation (UCS2 
or UCS4) is written instead of the actual text, which also directly contradicts 
documentation, which states "This is equivalent to calling write() for each 
string". However on Python 2.7.7+ they are no longer equivalent:

>>> open('testfile.bin', 'wb').writelines([u'Hello, world!'])
>>> open('testfile.bin', 'rb').read()
'H\x00e\x00l\x00l\x00o\x00,\x00 \x00w\x00o\x00r\x00l\x00d\x00!\x00'
>>> open('testfile.bin', 'wb').write(u'Hello, world!')
>>> open('testfile.bin', 'rb').read()
'Hello, world!'

This code worked correctly no Python 2.7.6.

--
components: IO
messages: 266605
nosy: snaury
priority: normal
severity: normal
status: open
title: Regression in file.writelines behavior
type: behavior
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com