From 4585fdef5ade0c6b50a8bc539246239aea1571b4 Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Date: Wed, 2 Dec 2026 14:41:40 +0200
Subject: [PATCH 1/3] Move Windows-only extension modules from PC/ to Modules/
---
.github/CODEOWNERS | 6 +++++-
Doc/library/msvcrt.rst | 2 +-
Doc/library/winreg.rst | 2 +-
Doc/library/winsound.rst | 2 +-
InternalDocs/structure.md | 2 +-
.../Build/2026-12-02-15-10-00.gh-issue-163009.Wm3pQz.rst | 3 +++
{PC => Modules}/_testconsole.c | 0
{PC => Modules}/_wmimodule.cpp | 0
{PC => Modules}/clinic/_testconsole.c.h | 0
{PC => Modules}/clinic/_wmimodule.cpp.h | 0
{PC => Modules}/clinic/msvcrtmodule.c.h | 0
{PC => Modules}/clinic/winreg.c.h | 0
{PC => Modules}/clinic/winsound.c.h | 0
{PC => Modules}/msvcrtmodule.c | 0
{PC => Modules}/winreg.c | 0
{PC => Modules}/winsound.c | 0
PCbuild/_freeze_module.vcxproj | 4 ++--
PCbuild/_freeze_module.vcxproj.filters | 4 ++--
PCbuild/_testconsole.vcxproj | 2 +-
PCbuild/_testconsole.vcxproj.filters | 2 +-
PCbuild/_wmi.vcxproj | 2 +-
PCbuild/_wmi.vcxproj.filters | 2 +-
PCbuild/pythoncore.vcxproj | 4 ++--
PCbuild/pythoncore.vcxproj.filters | 8 ++++----
PCbuild/winsound.vcxproj | 2 +-
PCbuild/winsound.vcxproj.filters | 2 +-
Tools/c-analyzer/cpython/_parser.py | 4 ++++
27 files changed, 32 insertions(+), 21 deletions(-)
create mode 100644 Misc/NEWS.d/next/Build/2026-12-02-15-10-00.gh-issue-163009.Wm3pQz.rst
rename {PC => Modules}/_testconsole.c (100%)
rename {PC => Modules}/_wmimodule.cpp (100%)
rename {PC => Modules}/clinic/_testconsole.c.h (100%)
rename {PC => Modules}/clinic/_wmimodule.cpp.h (100%)
rename {PC => Modules}/clinic/msvcrtmodule.c.h (100%)
rename {PC => Modules}/clinic/winreg.c.h (100%)
rename {PC => Modules}/clinic/winsound.c.h (100%)
rename {PC => Modules}/msvcrtmodule.c (100%)
rename {PC => Modules}/winreg.c (100%)
rename {PC => Modules}/winsound.c (100%)
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index a95eb943e4a4e7..b19f76bc4211cd 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -188,6 +188,11 @@ Tools/wasm/wasi @brettcannon @emmatyping @savannahostrowski
# Windows
PC/ @python/windows-team
PCbuild/ @python/windows-team
+Modules/_testconsole.c @python/windows-team
+Modules/_wmimodule.cpp @python/windows-team
+Modules/msvcrtmodule.c @python/windows-team
+Modules/winreg.c @python/windows-team
+Modules/winsound.c @python/windows-team
# Windows Venv launcher/redirector
PC/venvlauncher.c @python/windows-team @vsajip
@@ -675,7 +680,6 @@ Modules/_zstd/ @AA-Turner @emmatyping
# Exclude Argument Clinic directories
Modules/**/clinic/
Objects/**/clinic/
-PC/**/clinic/
Python/**/clinic/
# Exclude Lazy Imports=all CI carve out file
diff --git a/Doc/library/msvcrt.rst b/Doc/library/msvcrt.rst
index 27c73f81096ece..a2e15948bd408e 100644
--- a/Doc/library/msvcrt.rst
+++ b/Doc/library/msvcrt.rst
@@ -4,7 +4,7 @@
.. module:: msvcrt
:synopsis: Miscellaneous useful routines from the MS VC++ runtime.
-**Source code:** :source:`PC/msvcrtmodule.c`
+**Source code:** :source:`Modules/msvcrtmodule.c`
--------------
diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst
index 2353bfd5281dab..17219e6dad73e6 100644
--- a/Doc/library/winreg.rst
+++ b/Doc/library/winreg.rst
@@ -4,7 +4,7 @@
.. module:: winreg
:synopsis: Routines and objects for manipulating the Windows registry.
-**Source code:** :source:`PC/winreg.c`
+**Source code:** :source:`Modules/winreg.c`
--------------
diff --git a/Doc/library/winsound.rst b/Doc/library/winsound.rst
index 6b5f88021489d3..4f00775bcab750 100644
--- a/Doc/library/winsound.rst
+++ b/Doc/library/winsound.rst
@@ -4,7 +4,7 @@
.. module:: winsound
:synopsis: Access to the sound-playing machinery for Windows.
-**Source code:** :source:`PC/winsound.c`
+**Source code:** :source:`Modules/winsound.c`
--------------
diff --git a/InternalDocs/structure.md b/InternalDocs/structure.md
index 364773d6812690..d68f9342e3853f 100644
--- a/InternalDocs/structure.md
+++ b/InternalDocs/structure.md
@@ -37,4 +37,4 @@ Some exceptions to these layouts are:
* built-in type `str` is at [`Objects/unicodeobject.c`](../Objects/unicodeobject.c)
* built-in module `sys` is at [`Python/sysmodule.c`](../Python/sysmodule.c)
* built-in module `marshal` is at [`Python/marshal.c`](../Python/marshal.c)
-* Windows-only module `winreg` is at [`PC/winreg.c`](../PC/winreg.c)
+* Windows-only module `winreg` is at [`Modules/winreg.c`](../Modules/winreg.c)
diff --git a/Misc/NEWS.d/next/Build/2026-12-02-15-10-00.gh-issue-163009.Wm3pQz.rst b/Misc/NEWS.d/next/Build/2026-12-02-15-10-00.gh-issue-163009.Wm3pQz.rst
new file mode 100644
index 00000000000000..abf9b40bdee1bf
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-12-02-15-10-00.gh-issue-163009.Wm3pQz.rst
@@ -0,0 +1,3 @@
+Move the Windows-only extension modules :mod:`msvcrt`, :mod:`winreg`,
+:mod:`winsound`, ``_wmi`` and ``_testconsole`` from :file:`PC/` to
+:file:`Modules/`. Patch by Hugo van Kemenade.
diff --git a/PC/_testconsole.c b/Modules/_testconsole.c
similarity index 100%
rename from PC/_testconsole.c
rename to Modules/_testconsole.c
diff --git a/PC/_wmimodule.cpp b/Modules/_wmimodule.cpp
similarity index 100%
rename from PC/_wmimodule.cpp
rename to Modules/_wmimodule.cpp
diff --git a/PC/clinic/_testconsole.c.h b/Modules/clinic/_testconsole.c.h
similarity index 100%
rename from PC/clinic/_testconsole.c.h
rename to Modules/clinic/_testconsole.c.h
diff --git a/PC/clinic/_wmimodule.cpp.h b/Modules/clinic/_wmimodule.cpp.h
similarity index 100%
rename from PC/clinic/_wmimodule.cpp.h
rename to Modules/clinic/_wmimodule.cpp.h
diff --git a/PC/clinic/msvcrtmodule.c.h b/Modules/clinic/msvcrtmodule.c.h
similarity index 100%
rename from PC/clinic/msvcrtmodule.c.h
rename to Modules/clinic/msvcrtmodule.c.h
diff --git a/PC/clinic/winreg.c.h b/Modules/clinic/winreg.c.h
similarity index 100%
rename from PC/clinic/winreg.c.h
rename to Modules/clinic/winreg.c.h
diff --git a/PC/clinic/winsound.c.h b/Modules/clinic/winsound.c.h
similarity index 100%
rename from PC/clinic/winsound.c.h
rename to Modules/clinic/winsound.c.h
diff --git a/PC/msvcrtmodule.c b/Modules/msvcrtmodule.c
similarity index 100%
rename from PC/msvcrtmodule.c
rename to Modules/msvcrtmodule.c
diff --git a/PC/winreg.c b/Modules/winreg.c
similarity index 100%
rename from PC/winreg.c
rename to Modules/winreg.c
diff --git a/PC/winsound.c b/Modules/winsound.c
similarity index 100%
rename from PC/winsound.c
rename to Modules/winsound.c
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index bf430135e21ed5..6462abbca97e33 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -193,8 +193,8 @@
-
-
+
+
diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters
index 6ff943f89ade00..9c8376c2af1843 100644
--- a/PCbuild/_freeze_module.vcxproj.filters
+++ b/PCbuild/_freeze_module.vcxproj.filters
@@ -295,7 +295,7 @@
Source Files
-
+
Source Files
@@ -538,7 +538,7 @@
Source Files
-
+
Source Files
diff --git a/PCbuild/_testconsole.vcxproj b/PCbuild/_testconsole.vcxproj
index 69d312b17a5a62..db1b99ef1212f9 100644
--- a/PCbuild/_testconsole.vcxproj
+++ b/PCbuild/_testconsole.vcxproj
@@ -98,7 +98,7 @@
-
+
diff --git a/PCbuild/_testconsole.vcxproj.filters b/PCbuild/_testconsole.vcxproj.filters
index 321e17785fddbb..b0185e2d169a44 100644
--- a/PCbuild/_testconsole.vcxproj.filters
+++ b/PCbuild/_testconsole.vcxproj.filters
@@ -11,7 +11,7 @@
-
+
Source Files
diff --git a/PCbuild/_wmi.vcxproj b/PCbuild/_wmi.vcxproj
index 22fa8960982528..0d60816f8e9021 100644
--- a/PCbuild/_wmi.vcxproj
+++ b/PCbuild/_wmi.vcxproj
@@ -102,7 +102,7 @@
-
+
diff --git a/PCbuild/_wmi.vcxproj.filters b/PCbuild/_wmi.vcxproj.filters
index fa8046237a0b71..30a60a08dad9f1 100644
--- a/PCbuild/_wmi.vcxproj.filters
+++ b/PCbuild/_wmi.vcxproj.filters
@@ -10,7 +10,7 @@
-
+
Source Files
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index d16aa7b4254b45..08bc682b315d29 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -611,9 +611,9 @@
-
+
-
+
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 99b2631b673a80..102acbc164e30b 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -1382,8 +1382,8 @@
Parser
-
- PC
+
+ Modules
PC
@@ -1391,8 +1391,8 @@
PC
-
- PC
+
+ Modules
Python
diff --git a/PCbuild/winsound.vcxproj b/PCbuild/winsound.vcxproj
index c26029b15a339f..7b636e71b2e743 100644
--- a/PCbuild/winsound.vcxproj
+++ b/PCbuild/winsound.vcxproj
@@ -98,7 +98,7 @@
-
+
diff --git a/PCbuild/winsound.vcxproj.filters b/PCbuild/winsound.vcxproj.filters
index 6775802638205b..abf46eab6cbf8b 100644
--- a/PCbuild/winsound.vcxproj.filters
+++ b/PCbuild/winsound.vcxproj.filters
@@ -10,7 +10,7 @@
-
+
Source Files
diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py
index caac194d3b7efb..24599ec7511bfd 100644
--- a/Tools/c-analyzer/cpython/_parser.py
+++ b/Tools/c-analyzer/cpython/_parser.py
@@ -51,9 +51,13 @@ def format_tsv_lines(lines):
'Modules/_scproxy.c', # SystemConfiguration/SystemConfiguration.h
# Windows
+ 'Modules/_testconsole.c', # windows.h
'Modules/_winapi.c', # windows.h
'Modules/expat/winconfig.h',
+ 'Modules/msvcrtmodule.c', # windows.h
'Modules/overlapped.c', # winsock.h
+ 'Modules/winreg.c', # windows.h
+ 'Modules/winsound.c', # windows.h
'Python/dynload_win.c', # windows.h
'Python/thread_nt.h',
From bbfe536a5143b1bbd55d9ddaef5a8ce35ba15ddc Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Date: Wed, 2 Dec 2026 15:27:53 +0200
Subject: [PATCH 2/3] Fix check for generated files
---
Tools/c-analyzer/cpython/_analyzer.py | 2 +-
Tools/c-analyzer/cpython/ignored.tsv | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Tools/c-analyzer/cpython/_analyzer.py b/Tools/c-analyzer/cpython/_analyzer.py
index 404a81af11e39f..16a37eb6ab67e7 100644
--- a/Tools/c-analyzer/cpython/_analyzer.py
+++ b/Tools/c-analyzer/cpython/_analyzer.py
@@ -295,7 +295,7 @@ def _is_local_static_mutex(decl):
return (vartype.typespec == 'PyMutex') and (decl.storage == 'static')
def _has_other_supported_type(decl):
- if hasattr(decl, 'file') and decl.file.filename.endswith('.c.h'):
+ if hasattr(decl, 'file') and decl.file.filename.endswith(('.c.h', '.cpp.h')):
assert 'clinic' in decl.file.filename, (decl,)
if decl.name == '_kwtuple':
return True
diff --git a/Tools/c-analyzer/cpython/ignored.tsv b/Tools/c-analyzer/cpython/ignored.tsv
index 4b1039269377df..65209137418530 100644
--- a/Tools/c-analyzer/cpython/ignored.tsv
+++ b/Tools/c-analyzer/cpython/ignored.tsv
@@ -796,6 +796,9 @@ Modules/_zstd/_zstdmodule.c - _zstdmodule -
Modules/clinic/md5module.c.h _md5_md5 _keywords -
Modules/clinic/grpmodule.c.h grp_getgrgid _keywords -
Modules/clinic/grpmodule.c.h grp_getgrnam _keywords -
+Modules/clinic/winsound.c.h winsound_Beep _keywords -
+Modules/clinic/winsound.c.h winsound_MessageBeep _keywords -
+Modules/clinic/winsound.c.h winsound_PlaySound _keywords -
Objects/object.c - constants static PyObject*[]
Objects/dictobject.c - PyFrozenDict_Type -
Modules/_testcapi/unicode.c test_py_identifier PyId_hello -
From 027f2e537d3704e60992a5748c82dd684011979d Mon Sep 17 00:00:00 2001
From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Date: Thu, 3 Dec 2026 13:03:19 +0200
Subject: [PATCH 3/3] No longer an exception
Co-authored-by: Stan Ulbrych
---
InternalDocs/structure.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/InternalDocs/structure.md b/InternalDocs/structure.md
index d68f9342e3853f..17bad01c54a339 100644
--- a/InternalDocs/structure.md
+++ b/InternalDocs/structure.md
@@ -37,4 +37,3 @@ Some exceptions to these layouts are:
* built-in type `str` is at [`Objects/unicodeobject.c`](../Objects/unicodeobject.c)
* built-in module `sys` is at [`Python/sysmodule.c`](../Python/sysmodule.c)
* built-in module `marshal` is at [`Python/marshal.c`](../Python/marshal.c)
-* Windows-only module `winreg` is at [`Modules/winreg.c`](../Modules/winreg.c)