[issue26158] File truncate() not defaulting to current position as documented

2016-01-19 Thread Fornax
Fornax added the comment: I don't have a specific use case. This spawned from a tangentially-related StackOverflow question (http://stackoverflow.com/questions/34858088), where in the answers a behavior difference between Python 2 and 3 was noted. I couldn't find any documentation

[issue26158] File truncate() not defaulting to current position as documented

2016-01-19 Thread Fornax
Fornax added the comment: Another surprising result: >>> open('temp.txt', 'w').write('ABCDE\nFGHIJ\nKLMNO\nPQRST\nUVWXY\nZ\n') 32 >>> f = open('temp.txt', 'r+') >>> f.write('test') 4 >>> f.close

[issue26158] File truncate() not defaulting to current position as documented

2016-01-19 Thread Fornax
Fornax added the comment: After taking a little time to let this sink in, I'm going to play Devil's Advocate just a little more. It sounds like you're basically saying that any read-write text-based modes (e.g. r+, w+) should be used at your own peril. While I unders

[issue26158] File truncate() not defaulting to current position as documented

2016-01-19 Thread Fornax
Fornax added the comment: Heh... building on Serhiy's example: >>> f.tell() 680564735109527527154978616360239628288 I'm way out of my depth here. The results seem surprising, but I lack the experience to be able to say what they "should" look like. So I guess if

[issue26158] File truncate() not defaulting to current position as documented

2016-01-19 Thread Fornax
Fornax added the comment: To clarify... the intended behavior is for truncate to default to the current position of the buffer, rather than the current position as reported directly from the stream by tell? That seems... surprising. -- ___ Python

[issue26158] File truncate() not defaulting to current position as documented

2016-01-19 Thread Fornax
New submission from Fornax: io.IOBase.truncate() documentation says: "Resize the stream to the given size in bytes (or the current position if size is not specified). The current stream position isn’t changed. This resizing can extend or reduce the current file size. In case of extension