New submission from Yang Xiao:
There is a functionality bug in linecache library.
>>test.py<<
import linecache
def test_getline(f):
print linecache.getlines(f)
if __name__ == "__main__":
tf1 = 'aaa'
with open(tf1,'w') as f:
f.write('good morning\n')
test_getline(tf1)
tf2 = 'bbb'
with open(tf2,'w') as f:
f.write('good evening\n')
test_getline(tf2)
tf1 = 'aaa'
with open(tf1,'w') as f:
f.write('good morning 123\n')
test_getline(tf1)
tf2 = 'bbb'
with open(tf2,'w') as f:
f.write('good evening 123\n')
test_getline(tf2)
The expectant output shoule be:
['good morning\n']
['good evening\n']
['good morning\n']
['good evening\n']
However, the script above outputs below:
['good morning\n']
['good evening\n']
['good morning\n']
['good evening\n']
I think there is a bug about implementation of linecache library.
----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 296874
nosy: Yang Xiao
priority: normal
severity: normal
status: open
title: There is functionality bug in linecache library.
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com