mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Close #12015: The tempfile module now uses a suffix of 8 random characters
instead of 6, to reduce the risk of filename collision. The entropy was reduced when uppercase letters were removed from the charset used to generate random characters.
This commit is contained in:
parent
0c7907dd48
commit
97869103ba
3 changed files with 8 additions and 3 deletions
|
@ -125,7 +125,7 @@ class _RandomNameSequence:
|
|||
def __next__(self):
|
||||
c = self.characters
|
||||
choose = self.rng.choice
|
||||
letters = [choose(c) for dummy in "123456"]
|
||||
letters = [choose(c) for dummy in range(8)]
|
||||
return ''.join(letters)
|
||||
|
||||
def _candidate_tempdir_list():
|
||||
|
|
|
@ -35,7 +35,7 @@ else:
|
|||
# Common functionality.
|
||||
class BaseTestCase(unittest.TestCase):
|
||||
|
||||
str_check = re.compile(r"[a-zA-Z0-9_-]{6}$")
|
||||
str_check = re.compile(r"^[a-z0-9_-]{8}$")
|
||||
|
||||
def setUp(self):
|
||||
self._warnings_manager = support.check_warnings()
|
||||
|
@ -62,7 +62,7 @@ class BaseTestCase(unittest.TestCase):
|
|||
|
||||
nbase = nbase[len(pre):len(nbase)-len(suf)]
|
||||
self.assertTrue(self.str_check.match(nbase),
|
||||
"random string '%s' does not match /^[a-zA-Z0-9_-]{6}$/"
|
||||
"random string '%s' does not match ^[a-z0-9_-]{8}$"
|
||||
% nbase)
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #12015: The tempfile module now uses a suffix of 8 random characters
|
||||
instead of 6, to reduce the risk of filename collision. The entropy was
|
||||
reduced when uppercase letters were removed from the charset used to generate
|
||||
random characters.
|
||||
|
||||
- Issue #18585: Add :func:`textwrap.shorten` to collapse and truncate a
|
||||
piece of text to a given length.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue