[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for your review Victor. Will look on OpenIndiana buildbot. -- assignee: -> serhiy.storchaka resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue23838] linecache and MemoryError

2015-04-01 Thread Roundup Robot
Roundup Robot added the comment: New changeset d96e714a by Serhiy Storchaka in branch '2.7': Issue #23838: linecache now clears the cache and returns an empty result on https://hg.python.org/cpython/rev/d96e714a New changeset 88a0e6cd93c3 by Serhiy Storchaka in branch '3.4': Issue #23838

[issue23838] linecache and MemoryError

2015-04-01 Thread STINNER Victor
STINNER Victor added the comment: linecache_memoryerror_3.patch reviewed (comments on Rietveld). -- ___ Python tracker ___ ___ Python-

[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: On other side, linecache tests already use updatecache(). Here is a patch with a test. -- Added file: http://bugs.python.org/file38783/linecache_memoryerror_3.patch ___ Python tracker

[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This test depends on implementation details. I prefer to avoid adding such tests for trivial changes. -- ___ Python tracker ___ _

[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- type: -> resource usage versions: +Python 2.7, Python 3.4, Python 3.5 ___ Python tracker ___ ___ Pyt

[issue23838] linecache and MemoryError

2015-04-01 Thread STINNER Victor
STINNER Victor added the comment: > The question is left: should the patch be applied only on 3.5 or all versions? linecache_memoryerror_2.patch looks good to me, but it would be better with an unit test. IMO Python 2.7 and 3.4 can be fixed too. -- ___

[issue23838] linecache and MemoryError

2015-04-01 Thread STINNER Victor
STINNER Victor added the comment: > It is hard to write reliable test Ah? Why not using something like mock.patch('mock.updatecache', side_effect=MemoryError)? -- ___ Python tracker __

[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: OK, here is a patch that just clear the cache and returns an empty result. It is hard to write reliable test, but I think we will see the result on OpenIndiana buildbot. The question is left: should the patch be applied only on 3.5 or all versions?

[issue23838] linecache and MemoryError

2015-04-01 Thread STINNER Victor
STINNER Victor added the comment: 2015-04-01 14:02 GMT+02:00 Serhiy Storchaka : > getlines() already returns an empty list on OSError. Oh, I misread getlines(), you're right. > Clearing the cache on MemoryError will help to avoid other MemoryErrors. And > after this there is a large chance I

[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: getlines() already returns an empty list on OSError. Clearing the cache on MemoryError will help to avoid other MemoryErrors. And after this there is a large chance the repeated reading will be successful. In any case it wouldn't make worse. If don't change

[issue23838] linecache and MemoryError

2015-04-01 Thread STINNER Victor
STINNER Victor added the comment: Serhiy: you look to be interested in fixing Python to not fail badly under low memory condition. You may take a look at #19817 which proposes a function to arbitrary limit the memory allocated to Python. I fixed a lot of issues found by failmalloc, but they ar

[issue23838] linecache and MemoryError

2015-04-01 Thread STINNER Victor
STINNER Victor added the comment: > Proposed patch clears the cache and repeats an attempt to read source file, > and returns empty result if the second attempt fails (as when the source file > can't be read). IMO it's a bad idea. You should not retry an operation on MemoryError but only do y

[issue23838] linecache and MemoryError

2015-04-01 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: When format a traceback of MemoryError, linecache tries to read all lines of source file and likely raises a MemoryError. For example: http://buildbot.python.org/all/builders/x86%20OpenIndiana%203.x/builds/9712/steps/test/logs/stdio Traceback (most recent