[issue22719] os.path.isfile os.path.exists bug in while loop

2014-11-10 Thread Aaron
Aaron added the comment: Python 3.3.0, Windows 7, both 64 bit. Has it been resolved with the newer version, then? On Mon, Nov 3, 2014 at 11:15 PM, Zachary Ware rep...@bugs.python.org wrote: Zachary Ware added the comment: Aaron, what version of Python are you using on what version of

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-11-10 Thread Zachary Ware
Zachary Ware added the comment: I haven't built 3.3.0 again yet to try to reproduce with it, but there have been enough bug and security fixes in the more recent 3.3 releases that I'd strongly advise updating on general principle and seeing if this issue goes away. If not to 3.4.2, at least to

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-11-10 Thread Zachary Ware
Zachary Ware added the comment: I have had a chance to build 3.3.0 and I was able to reproduce the bug with it, so it is in fact fixed in later versions. -- resolution: - out of date stage: - resolved status: open - closed ___ Python tracker

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-11-03 Thread Zachary Ware
Zachary Ware added the comment: Aaron, what version of Python are you using on what version of Windows? Also, 32 or 64 bit on both? I can't reproduce this with any Python 3.3.6 or newer on 64-bit Windows 8.1. -- ___ Python tracker

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread Aaron
Changes by Aaron hosfor...@gmail.com: -- title: os.path.isfile os.path.exists but in while loop - os.path.isfile os.path.exists bug in while loop ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22719

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread R. David Murray
R. David Murray added the comment: Interesting bug. The obvious difference between the two cases is that in the += version the address of the string pointing to the filepath doesn't change, whereas when you use a temp variable it does (there's an optimization in += that reuses the same

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread Steve Dower
Steve Dower added the comment: I wonder whether the same thing occurs if you're not appending a new extension each time? There could be some optimisation (from the dark old days of 8.3 filename) that compares baseExcel and .bak separately and assumes that the name is known. Last I looked at

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Could we encode both paths to the unicode_internal encoding and check if results are equal? -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22719

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread R. David Murray
R. David Murray added the comment: Looking at the code, it looks like it calls the win32 api directly if path-wide is true, which I'm guessing is the case unless you are using bytes paths in windows? It looks like the critical call, then, is CreateFileA (why A in a _w method I have no

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread eryksun
eryksun added the comment: What do you get for os.stat? bak_path = rC:\Users\EAARHOS\Desktop\Python Review\baseExcel.py print(os.stat(bak_path)) bak_path += '.bak' print(os.stat(bak_path)) bak_path += '.bak' print(os.stat(bak_path)) # This should raise FileNotFoundError

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread Aaron
Aaron added the comment: Interesting. It continues to reuse the last one's stats once the path is no longer valid. bak_path = rC:\Users\EAARHOS\Desktop\Python Review\baseExcel.py print(os.stat(bak_path)) nt.stat_result(st_mode=33206, st_ino=8162774324652726, st_dev=0, st_nlink=1, st_uid=0,

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread Aaron
Aaron added the comment: If I use a separate temp variable, the bug doesn't show, but if I use the same variable, even with + instead of +=, it still happens. bak_path = rC:\Users\EAARHOS\Desktop\Python Review\baseExcel.py print(os.stat(bak_path)) nt.stat_result(st_mode=33206,

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread eryksun
eryksun added the comment: When appending to a singly-referenced string, the interpreter tries to reallocate the string in place. This applies to both `s += 'text'` and `s = s + 'text'`. Storing to a temp variable is adding a 2nd reference, so a new string gets allocated instead. If the

[issue22719] os.path.isfile os.path.exists bug in while loop

2014-10-24 Thread eryksun
eryksun added the comment: i.e. the object id is the same after appending Actually, that's wrong. bak_path is a compact string. So the whole object is realloc'd, and the base address (i.e. id) could change. Check PyUnicode_AsUnicode even if the id changes. --