Skip to content

Commit d83faf7

Browse files
authored
gh-103092: Isolate winreg (#103250)
1 parent eb5fd31 commit d83faf7

File tree

5 files changed

+196
-152
lines changed

5 files changed

+196
-152
lines changed

Lib/test/test_winreg.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Test the windows specific win32reg module.
22
# Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey
33

4+
import gc
45
import os, sys, errno
5-
import unittest
6-
from test.support import import_helper
76
import threading
7+
import unittest
88
from platform import machine, win32_edition
9+
from test.support import cpython_only, import_helper
910

1011
# Do this first so test will be skipped if module doesn't exist
1112
import_helper.import_module('winreg', required_on=['win'])
@@ -49,6 +50,17 @@
4950
("Japanese 日本", "日本語", REG_SZ),
5051
]
5152

53+
54+
@cpython_only
55+
class HeapTypeTests(unittest.TestCase):
56+
def test_have_gc(self):
57+
self.assertTrue(gc.is_tracked(HKEYType))
58+
59+
def test_immutable(self):
60+
with self.assertRaisesRegex(TypeError, "immutable"):
61+
HKEYType.foo = "bar"
62+
63+
5264
class BaseWinregTests(unittest.TestCase):
5365

5466
def setUp(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adapt the :mod:`winreg` extension module to :pep:`687`.

Objects/object.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,6 @@ PyObject _Py_NotImplementedStruct = {
19651965
1, &_PyNotImplemented_Type
19661966
};
19671967

1968-
#ifdef MS_WINDOWS
1969-
extern PyTypeObject PyHKEY_Type;
1970-
#endif
19711968
extern PyTypeObject _Py_GenericAliasIterType;
19721969
extern PyTypeObject _PyMemoryIter_Type;
19731970
extern PyTypeObject _PyLineIterator;
@@ -2018,9 +2015,6 @@ static PyTypeObject* static_types[] = {
20182015
&PyFunction_Type,
20192016
&PyGen_Type,
20202017
&PyGetSetDescr_Type,
2021-
#ifdef MS_WINDOWS
2022-
&PyHKEY_Type,
2023-
#endif
20242018
&PyInstanceMethod_Type,
20252019
&PyListIter_Type,
20262020
&PyListRevIter_Type,

PC/clinic/winreg.c.h

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)