summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/shared_memory.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-08-30 19:42:22 (GMT)
committerGitHub <noreply@github.com>2020-08-30 19:42:22 (GMT)
commitca55ecbf9aab305fa301ec69410ca3d3d18ec848 (patch)
tree87a95832befa4610738be966fa3340e6b12ac57a /Lib/multiprocessing/shared_memory.py
parent901c2eae6e27ee7793e5a3c638664e01a3bf8de8 (diff)
downloadcpython-ca55ecbf9aab305fa301ec69410ca3d3d18ec848.zip
cpython-ca55ecbf9aab305fa301ec69410ca3d3d18ec848.tar.gz
cpython-ca55ecbf9aab305fa301ec69410ca3d3d18ec848.tar.bz2
bpo-41344: Raise ValueError when creating shared memory of size 0 (GH-21556) (GH-22018)
(cherry picked from commit 475a5fbb5644ea200c990d85d8c264e78ab6c7ea) Co-authored-by: Vinay Sharma <vinay04sharma@icloud.com> Co-authored-by: Vinay Sharma <vinay04sharma@icloud.com>
Diffstat (limited to 'Lib/multiprocessing/shared_memory.py')
-rw-r--r--Lib/multiprocessing/shared_memory.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/multiprocessing/shared_memory.py b/Lib/multiprocessing/shared_memory.py
index a3a5fcf..122b3fc 100644
--- a/Lib/multiprocessing/shared_memory.py
+++ b/Lib/multiprocessing/shared_memory.py
@@ -76,6 +76,8 @@ class SharedMemory:
raise ValueError("'size' must be a positive integer")
if create:
self._flags = _O_CREX | os.O_RDWR
+ if size == 0:
+ raise ValueError("'size' must be a positive number different from zero")
if name is None and not self._flags & os.O_EXCL:
raise ValueError("'name' can only be None if create=True")