Skip to content

Commit

Permalink
updated to 3.12.5, 3.13.0rc1, 7.3.17 (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns authored Aug 29, 2024
1 parent 1bbf5f3 commit 08e4266
Show file tree
Hide file tree
Showing 20 changed files with 372 additions and 27 deletions.
41 changes: 40 additions & 1 deletion py3.12/README_MODS
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ diff Python-3.12.0b4/Lib/test/_test_multiprocessing.py Python-3.12.0rc2/Lib/test
> continue
>
# ----------------------------------------------------------------------
$ diff Python-3.12.0rc2/Lib/test/_test_multiprocessing.py Python-3.12.0rc3/Lib/test/_test_multiprocessing.py
diff Python-3.12.0rc2/Lib/test/_test_multiprocessing.py Python-3.12.0rc3/Lib/test/_test_multiprocessing.py
677a678
> @support.requires_resource('walltime')
4955a4957
Expand Down Expand Up @@ -1575,3 +1575,42 @@ diff Python-3.12.2/Lib/test/_test_multiprocessing.py Python-3.12.3/Lib/test/_tes
< def test_invalid_shared_memory_cration(self):
---
> def test_invalid_shared_memory_creation(self):
# ----------------------------------------------------------------------
diff Python-3.12.3/Lib/test/_test_multiprocessing.py Python-3.12.5/Lib/test/_test_multiprocessing.py
25d24
< import pathlib
327,328c326,328
< sys.executable.encode(), # bytes
< pathlib.Path(sys.executable) # os.PathLike
---
> os.fsencode(sys.executable), # bytes
> os_helper.FakePath(sys.executable), # os.PathLike
> os_helper.FakePath(os.fsencode(sys.executable)), # os.PathLike bytes
1334a1335,1351
> def test_closed_queue_empty_exceptions(self):
> # Assert that checking the emptiness of an unused closed queue
> # does not raise an OSError. The rationale is that q.close() is
> # a no-op upon construction and becomes effective once the queue
> # has been used (e.g., by calling q.put()).
> for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
> q.close() # this is a no-op since the feeder thread is None
> q.join_thread() # this is also a no-op
> self.assertTrue(q.empty())
>
> for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
> q.put('foo') # make sure that the queue is 'used'
> q.close() # close the feeder thread
> q.join_thread() # make sure to join the feeder thread
> with self.assertRaisesRegex(OSError, 'is closed'):
> q.empty()
>
5693a5711,5719
> def test_empty_exceptions(self):
> # Assert that checking emptiness of a closed queue raises
> # an OSError, independently of whether the queue was used
> # or not. This differs from Queue and JoinableQueue.
> q = multiprocessing.SimpleQueue()
> q.close() # close the pipe
> with self.assertRaisesRegex(OSError, 'is closed'):
> q.empty()
>
32 changes: 29 additions & 3 deletions py3.12/multiprocess/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import subprocess
import struct
import operator
import pathlib
import pickle #XXX: use dill?
import weakref
import warnings
Expand Down Expand Up @@ -331,8 +330,9 @@ def test_set_executable(self):
self.skipTest(f'test not appropriate for {self.TYPE}')
paths = [
sys.executable, # str
sys.executable.encode(), # bytes
pathlib.Path(sys.executable) # os.PathLike
os.fsencode(sys.executable), # bytes
os_helper.FakePath(sys.executable), # os.PathLike
os_helper.FakePath(os.fsencode(sys.executable)), # os.PathLike bytes
]
for path in paths:
self.set_executable(path)
Expand Down Expand Up @@ -1340,6 +1340,23 @@ def _on_queue_feeder_error(e, obj):
self.assertTrue(not_serializable_obj.reduce_was_called)
self.assertTrue(not_serializable_obj.on_queue_feeder_error_was_called)

def test_closed_queue_empty_exceptions(self):
# Assert that checking the emptiness of an unused closed queue
# does not raise an OSError. The rationale is that q.close() is
# a no-op upon construction and becomes effective once the queue
# has been used (e.g., by calling q.put()).
for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
q.close() # this is a no-op since the feeder thread is None
q.join_thread() # this is also a no-op
self.assertTrue(q.empty())

for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
q.put('foo') # make sure that the queue is 'used'
q.close() # close the feeder thread
q.join_thread() # make sure to join the feeder thread
with self.assertRaisesRegex(OSError, 'is closed'):
q.empty()

def test_closed_queue_put_get_exceptions(self):
for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
q.close()
Expand Down Expand Up @@ -5703,6 +5720,15 @@ def _test_empty(cls, queue, child_can_start, parent_can_continue):
finally:
parent_can_continue.set()

def test_empty_exceptions(self):
# Assert that checking emptiness of a closed queue raises
# an OSError, independently of whether the queue was used
# or not. This differs from Queue and JoinableQueue.
q = multiprocessing.SimpleQueue()
q.close() # close the pipe
with self.assertRaisesRegex(OSError, 'is closed'):
q.empty()

def test_empty(self):
queue = multiprocessing.SimpleQueue()
child_can_start = multiprocessing.Event()
Expand Down
41 changes: 36 additions & 5 deletions py3.13/Modules/_multiprocess/clinic/semaphore.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ preserve
# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()

#if defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS)
Expand Down Expand Up @@ -75,7 +76,9 @@ _multiprocessing_SemLock_acquire(SemLockObject *self, PyObject *const *args, Py_
}
timeout_obj = args[1];
skip_optional_pos:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock_acquire_impl(self, blocking, timeout_obj);
Py_END_CRITICAL_SECTION();

exit:
return return_value;
Expand All @@ -100,7 +103,13 @@ _multiprocessing_SemLock_release_impl(SemLockObject *self);
static PyObject *
_multiprocessing_SemLock_release(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
return _multiprocessing_SemLock_release_impl(self);
PyObject *return_value = NULL;

Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock_release_impl(self);
Py_END_CRITICAL_SECTION();

return return_value;
}

#endif /* defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) */
Expand Down Expand Up @@ -172,7 +181,9 @@ _multiprocessing_SemLock_acquire(SemLockObject *self, PyObject *const *args, Py_
}
timeout_obj = args[1];
skip_optional_pos:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock_acquire_impl(self, blocking, timeout_obj);
Py_END_CRITICAL_SECTION();

exit:
return return_value;
Expand All @@ -197,7 +208,13 @@ _multiprocessing_SemLock_release_impl(SemLockObject *self);
static PyObject *
_multiprocessing_SemLock_release(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
return _multiprocessing_SemLock_release_impl(self);
PyObject *return_value = NULL;

Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock_release_impl(self);
Py_END_CRITICAL_SECTION();

return return_value;
}

#endif /* defined(HAVE_MP_SEMAPHORE) && !defined(MS_WINDOWS) */
Expand Down Expand Up @@ -340,7 +357,13 @@ _multiprocessing_SemLock__count_impl(SemLockObject *self);
static PyObject *
_multiprocessing_SemLock__count(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
return _multiprocessing_SemLock__count_impl(self);
PyObject *return_value = NULL;

Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock__count_impl(self);
Py_END_CRITICAL_SECTION();

return return_value;
}

#endif /* defined(HAVE_MP_SEMAPHORE) */
Expand Down Expand Up @@ -450,7 +473,13 @@ _multiprocessing_SemLock___enter___impl(SemLockObject *self);
static PyObject *
_multiprocessing_SemLock___enter__(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
return _multiprocessing_SemLock___enter___impl(self);
PyObject *return_value = NULL;

Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock___enter___impl(self);
Py_END_CRITICAL_SECTION();

return return_value;
}

#endif /* defined(HAVE_MP_SEMAPHORE) */
Expand Down Expand Up @@ -495,7 +524,9 @@ _multiprocessing_SemLock___exit__(SemLockObject *self, PyObject *const *args, Py
}
exc_tb = args[2];
skip_optional:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock___exit___impl(self, exc_type, exc_value, exc_tb);
Py_END_CRITICAL_SECTION();

exit:
return return_value;
Expand Down Expand Up @@ -542,4 +573,4 @@ _multiprocessing_SemLock___exit__(SemLockObject *self, PyObject *const *args, Py
#ifndef _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
#define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
#endif /* !defined(_MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF) */
/*[clinic end generated code: output=d57992037e6770b6 input=a9049054013a1b77]*/
/*[clinic end generated code: output=dea36482d23a355f input=a9049054013a1b77]*/
1 change: 1 addition & 0 deletions py3.13/Modules/_multiprocess/multiprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ multiprocess_exec(PyObject *module)
static PyModuleDef_Slot multiprocess_slots[] = {
{Py_mod_exec, multiprocess_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

Expand Down
5 changes: 3 additions & 2 deletions py3.13/Modules/_multiprocess/posixshmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
posixshmem - A Python extension that provides shm_open() and shm_unlink()
*/

// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif

#include <Python.h>
Expand Down Expand Up @@ -128,6 +128,7 @@ static PyMethodDef module_methods[ ] = {

static PyModuleDef_Slot module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

Expand Down
6 changes: 4 additions & 2 deletions py3.13/Modules/_multiprocess/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,19 +682,21 @@ _multiprocess_SemLock__after_fork_impl(SemLockObject *self)
}

/*[clinic input]
@critical_section
_multiprocess.SemLock.__enter__
Enter the semaphore/lock.
[clinic start generated code]*/

static PyObject *
_multiprocess_SemLock___enter___impl(SemLockObject *self)
/*[clinic end generated code: output=beeb2f07c858511f input=c5e27d594284690b]*/
/*[clinic end generated code: output=beeb2f07c858511f input=d35c9860992ee790]*/
{
return _multiprocess_SemLock_acquire_impl(self, 1, Py_None);
}

/*[clinic input]
@critical_section
_multiprocess.SemLock.__exit__
exc_type: object = None
Expand All @@ -709,7 +711,7 @@ static PyObject *
_multiprocess_SemLock___exit___impl(SemLockObject *self,
PyObject *exc_type,
PyObject *exc_value, PyObject *exc_tb)
/*[clinic end generated code: output=3b37c1a9f8b91a03 input=7d644b64a89903f8]*/
/*[clinic end generated code: output=3b37c1a9f8b91a03 input=1610c8cc3e0e337e]*/
{
return _multiprocess_SemLock_release_impl(self);
}
Expand Down
Loading

0 comments on commit 08e4266

Please sign in to comment.