Changes between Initial Version and Version 2 of Ticket #15768
- Timestamp:
- Apr 5, 2011, 8:21:51 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #15768
- Property Triage Stage Unreviewed → Accepted
- Property Type Uncategorized → Cleanup/optimization
-
Ticket #15768 – Description
initial v2 1 The tempfile.mktemp() function is deprecated and the documentation warns that the "Use of this function may introduce a security hole in your program" - see [0] for more information. 2 The setUp() method FileStorageTests in tests/regressiontests/file_storage/tests.py uses tempfile.mktemp() in creating a temporary directory. The temporary directory is then deleted during tearDown(). See [1] for a snippet of the code in question. 1 The {{{tempfile.mktemp()}}} function is deprecated and the documentation warns that the "Use of this function may introduce a security hole in your program" - see http://docs.python.org/library/tempfile.html#tempfile.mktemp for more information. 3 2 4 Th is seems like a mistake because other classes such as FileSaveRaceConditionTest use tempfile.mkdtemp(). tempfile.mkdtemp is a safer way of creating a temporary directory.3 The {{{setUp()}}} method {{{FileStorageTests}}} in tests/regressiontests/file_storage/tests.py uses {{{tempfile.mktemp()}}} in creating a temporary directory. The temporary directory is then deleted during {{{tearDown()}}}: 5 4 6 Something like the following (_NOTE_: I haven't tested this) could be a 'fix'. 7 - self.temp_dir = tempfile.mktemp() 8 - os.makedirs(self.temp_dir) 9 + self.temp_dir = tempfile.mkdtemp() 10 11 12 13 [0] - http://docs.python.org/library/tempfile.html#tempfile.mktemp 14 15 [1] 5 {{{ 6 #!python 16 7 class FileStorageTests(unittest.TestCase): 17 8 storage_class = FileSystemStorage … … 25 16 def tearDown(self): 26 17 shutil.rmtree(self.temp_dir) 18 }}} 19 20 This seems like a mistake because other classes such as {{{FileSaveRaceConditionTest}}} use {{{tempfile.mkdtemp()}}}. {{{tempfile.mkdtemp}}} is a safer way of creating a temporary directory. 21 22 Something like the following (_NOTE_: I haven't tested this) could be a 'fix'. 23 {{{ 24 - self.temp_dir = tempfile.mktemp() 25 - os.makedirs(self.temp_dir) 26 + self.temp_dir = tempfile.mkdtemp() 27 }}} 28