From f2ca1581cab2da45880198af1c924dd40ec8a10b Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Sat, 29 Nov 2025 21:43:06 +0100
Subject: [PATCH 1/2] GH-141808: Do not generate the jit stencils twice in case
of PGO builds on Windows. (GH-142043)
* do not build the jit stencils twice in case of PGO builds on Windows
* blurb it
---
.../next/Build/2025-11-28-19-49-01.gh-issue-141808.cV5K12.rst | 1 +
PCbuild/pyproject.props | 1 +
2 files changed, 2 insertions(+)
create mode 100644 Misc/NEWS.d/next/Build/2025-11-28-19-49-01.gh-issue-141808.cV5K12.rst
diff --git a/Misc/NEWS.d/next/Build/2025-11-28-19-49-01.gh-issue-141808.cV5K12.rst b/Misc/NEWS.d/next/Build/2025-11-28-19-49-01.gh-issue-141808.cV5K12.rst
new file mode 100644
index 00000000000000..3162c7c41418cc
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2025-11-28-19-49-01.gh-issue-141808.cV5K12.rst
@@ -0,0 +1 @@
+Do not generate the jit stencils twice in case of PGO builds on Windows.
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
index cf35e705f355a7..53bfe5e3ea95cc 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -13,6 +13,7 @@
$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_frozen\
$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\zlib-ng\
$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_$(Configuration)
+ $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_PGInstrument
$(ProjectName)
$(TargetName)$(PyDebugExt)
false
From db098a475a47b16d25c88d95dbcf0c6572c68576 Mon Sep 17 00:00:00 2001
From: Duprat
Date: Sat, 29 Nov 2025 23:12:48 +0100
Subject: [PATCH 2/2] gh-133146: Add the old public `get_value` method to
documentation and refactor code. (GH-133301)
also uses it within the internals in a few places.
---
Doc/library/multiprocessing.rst | 10 ++++++++++
Lib/multiprocessing/queues.py | 2 +-
Lib/multiprocessing/synchronize.py | 13 +++++++++----
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index 714207cb0aefcd..cbc98b256a93a4 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -1577,12 +1577,22 @@ object -- see :ref:`multiprocessing-managers`.
A solitary difference from its close analog exists: its ``acquire`` method's
first argument is named *block*, as is consistent with :meth:`Lock.acquire`.
+
+ .. method:: get_value()
+
+ Return the current value of semaphore.
+
+ Note that this may raise :exc:`NotImplementedError` on platforms like
+ macOS where ``sem_getvalue()`` is not implemented.
+
+
.. method:: locked()
Return a boolean indicating whether this object is locked right now.
.. versionadded:: 3.14
+
.. note::
On macOS, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 925f043900004e..981599acf5ef26 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -121,7 +121,7 @@ def get(self, block=True, timeout=None):
def qsize(self):
# Raises NotImplementedError on Mac OSX because of broken sem_getvalue()
- return self._maxsize - self._sem._semlock._get_value()
+ return self._maxsize - self._sem.get_value()
def empty(self):
return not self._poll()
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py
index 30425047e9801a..9188114ae284c7 100644
--- a/Lib/multiprocessing/synchronize.py
+++ b/Lib/multiprocessing/synchronize.py
@@ -135,11 +135,16 @@ def __init__(self, value=1, *, ctx):
SemLock.__init__(self, SEMAPHORE, value, SEM_VALUE_MAX, ctx=ctx)
def get_value(self):
+ '''Returns current value of Semaphore.
+
+ Raises NotImplementedError on Mac OSX
+ because of broken sem_getvalue().
+ '''
return self._semlock._get_value()
def __repr__(self):
try:
- value = self._semlock._get_value()
+ value = self.get_value()
except Exception:
value = 'unknown'
return '<%s(value=%s)>' % (self.__class__.__name__, value)
@@ -155,7 +160,7 @@ def __init__(self, value=1, *, ctx):
def __repr__(self):
try:
- value = self._semlock._get_value()
+ value = self.get_value()
except Exception:
value = 'unknown'
return '<%s(value=%s, maxvalue=%s)>' % \
@@ -247,8 +252,8 @@ def _make_methods(self):
def __repr__(self):
try:
- num_waiters = (self._sleeping_count._semlock._get_value() -
- self._woken_count._semlock._get_value())
+ num_waiters = (self._sleeping_count.get_value() -
+ self._woken_count.get_value())
except Exception:
num_waiters = 'unknown'
return '<%s(%s, %s)>' % (self.__class__.__name__, self._lock, num_waiters)