strange Python version-dependent behavior with writing sorted output using heapq.merge -


Some GSUTL users have reported a failure while running GSUTL rsync, which I have apparently tracked to a Python 2.7.

.8-specific problem: we have the source and destination directory of synchronization in binary mode ('W + B') Write the sorted lists, and then read these lists back in Binary Mode ('RB') too. It works fine under Python 2.6.x and Python 2.7.3, but output under Python 2.7.8 ends in a pervert-looking binary format, which reads when it is being read back.

If I switch the output to solve the problem instead of using the 'w +' mode, (a) I think I want to write in binary mode because these files are unicode And (b) I want to understand why this is a Python version-dependent problem.

Someone may even have reason to do so.

FYI, I tried to reproduce this problem with a short program, which just writes one file in binary mode and read it back in binary mode, but the problem with this program Repro is not i am wondering what is pak There may be something about the implementation of the merge that has changed to Python 2.7.8 which can explain this problem (we sort in batches, and the individual sorted files are ok; Which happens

It seems to me that the file object is not properly flushed or read There is no search between and writing, or vice versa, a binary object will become more sensitive on this because the OS will not be able to translate into newline. Undetermined behaviors can be triggered at the C level and without initial memory reading or writing There is a python problem about it.

Why has it changed in a python minor version, though it is interesting, and if you have a copy So is the case of the price offered, you should definitely report.

If you're just writing Unicode, I encode UTF Unicode encoding; UTF-8 will never use newline bytes in other codepoints, for that you not need to use a binary file mode.

Alternatively, use the OpenOffice.org file to open a Unicode-aware file.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -