From 3581a7765c638322f21de71348a6de74e4a1a391 Mon Sep 17 00:00:00 2001 From: Clayton Parnell Date: Mon, 1 May 2023 15:09:20 -0400 Subject: [PATCH] Update to use NamedTemporaryFile rather than mktemp --- py3.10/multiprocess/connection.py | 6 +++--- py3.11/multiprocess/connection.py | 6 +++--- py3.12/multiprocess/connection.py | 6 +++--- py3.7/multiprocess/connection.py | 6 +++--- py3.8/multiprocess/connection.py | 6 +++--- py3.9/multiprocess/connection.py | 6 +++--- pypy3.7/multiprocess/connection.py | 6 +++--- pypy3.8/multiprocess/connection.py | 6 +++--- pypy3.9/multiprocess/connection.py | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/py3.10/multiprocess/connection.py b/py3.10/multiprocess/connection.py index aa23c04..e5b0470 100644 --- a/py3.10/multiprocess/connection.py +++ b/py3.10/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/py3.11/multiprocess/connection.py b/py3.11/multiprocess/connection.py index ac26dd1..3d02683 100644 --- a/py3.11/multiprocess/connection.py +++ b/py3.11/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/py3.12/multiprocess/connection.py b/py3.12/multiprocess/connection.py index c1b9d96..8b35f74 100644 --- a/py3.12/multiprocess/connection.py +++ b/py3.12/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/py3.7/multiprocess/connection.py b/py3.7/multiprocess/connection.py index 21abacc..eee9dc8 100644 --- a/py3.7/multiprocess/connection.py +++ b/py3.7/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/py3.8/multiprocess/connection.py b/py3.8/multiprocess/connection.py index aa23c04..e5b0470 100644 --- a/py3.8/multiprocess/connection.py +++ b/py3.8/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/py3.9/multiprocess/connection.py b/py3.9/multiprocess/connection.py index aa23c04..e5b0470 100644 --- a/py3.9/multiprocess/connection.py +++ b/py3.9/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/pypy3.7/multiprocess/connection.py b/pypy3.7/multiprocess/connection.py index 21abacc..eee9dc8 100644 --- a/pypy3.7/multiprocess/connection.py +++ b/pypy3.7/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/pypy3.8/multiprocess/connection.py b/pypy3.8/multiprocess/connection.py index aa23c04..e5b0470 100644 --- a/pypy3.8/multiprocess/connection.py +++ b/pypy3.8/multiprocess/connection.py @@ -76,10 +76,10 @@ def arbitrary_address(family): if family == 'AF_INET': return ('localhost', 0) elif family == 'AF_UNIX': - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family') diff --git a/pypy3.9/multiprocess/connection.py b/pypy3.9/multiprocess/connection.py index 235c48e..41b39a9 100644 --- a/pypy3.9/multiprocess/connection.py +++ b/pypy3.9/multiprocess/connection.py @@ -81,10 +81,10 @@ def arbitrary_address(family): # sun_path as short as 92 bytes in the sockaddr_un struct. if util.abstract_sockets_supported: return f"\0listener-{os.getpid()}-{next(_mmap_counter)}" - return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir()) + return tempfile.NamedTemporaryFile(prefix='listener-', dir=util.get_temp_dir(), delete=False) elif family == 'AF_PIPE': - return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' % - (os.getpid(), next(_mmap_counter)), dir="") + return tempfile.NamedTemporaryFile(prefix=r'\\.\pipe\pyc-%d-%d-' % + (os.getpid(), next(_mmap_counter)), dir="", delete=False) else: raise ValueError('unrecognized family')