Changes between Initial Version and Version 2 of Ticket #15768


Ignore:
Timestamp:
Apr 5, 2011, 8:21:51 AM (14 years ago)
Author:
Łukasz Rekucki
Comment:

Reformated description so it's easier to read.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15768

    • Property Triage Stage UnreviewedAccepted
    • Property Type UncategorizedCleanup/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.
     1The {{{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.
    32
    4 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.
     3The {{{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()}}}:
    54
    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
    167class FileStorageTests(unittest.TestCase):
    178    storage_class = FileSystemStorage
     
    2516    def tearDown(self):
    2617        shutil.rmtree(self.temp_dir)
     18}}}
     19
     20This 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
     22Something 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
Back to Top