New submission from Alexander Steppke <astep...@gmail.com>: The tempfile module shows strange behavior under certain conditions. This might lead to data leaking or other problems.
The test session looks as follows: Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tempfile >>> tmp = tempfile.TemporaryFile() >>> tmp.read() '' >>> tmp.write('test') >>> tmp.read() 'P\xf6D\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ [ommitted]' or similar behavior in text mode: Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tempfile >>> tmp = tempfile.TemporaryFile('w+t') >>> tmp.read() '' >>> tmp.write('test') >>> tmp.read() '\x00\xa5\x8b\x02int or long, hash(a) is used instead.\n i\x10 [ommitted]' >>> tmp.seek(0) >>> tmp.readline() 'test\x00\xa5\x8b\x02int or long, hash(a) is used instead.\n' This bug seems to be triggered by calling tmp.read() before tmp.seek(). I am running Python 2.7.2 on Windows 7 x64, other people have reproduced the problem on Windows XP but not under Linux or Cygwin (see also http://stackoverflow.com/questions/7757663/python-tempfile-broken-or-am-i-doing-it-wrong). Thank you for looking into this. Alexander ---------- components: Library (Lib), Windows messages: 145477 nosy: Alexander.Steppke priority: normal severity: normal status: open title: Bug in tempfile module type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13171> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com