mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Fix tempfile to not use random.Random
This commit is contained in:
3 files changed
+9
-4
No files matched your search
@@ -14,7 +14,7 @@ import itertools
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
# import tempfile
|
||||
import tempfile
|
||||
import warnings
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import sys
|
||||
import socket
|
||||
import struct
|
||||
import time
|
||||
#import tempfile
|
||||
import tempfile
|
||||
import itertools
|
||||
|
||||
import _multiprocessing
|
||||
|
||||
Vendored
+7
-2
@@ -42,7 +42,8 @@ import io as _io
|
||||
import os as _os
|
||||
import shutil as _shutil
|
||||
import errno as _errno
|
||||
from random import Random as _Random
|
||||
# XXX RustPython TODO: _random
|
||||
#from random import Random as _Random
|
||||
import weakref as _weakref
|
||||
|
||||
try:
|
||||
@@ -156,7 +157,11 @@ class _RandomNameSequence:
|
||||
|
||||
def __next__(self):
|
||||
c = self.characters
|
||||
choose = self.rng.choice
|
||||
def choose(s):
|
||||
import math, random
|
||||
return s[math.floor(random.random() * len(s))]
|
||||
# XXX RustPython TODO: proper random impl
|
||||
# choose = self.rng.choose
|
||||
letters = [choose(c) for dummy in range(8)]
|
||||
return ''.join(letters)
|
||||
|
||||
|
||||
Reference in new issue
Block a user