Skip to content

Commit 105d82a

Browse files
authored
Merge branch 'main' into fix-issue-43633
2 parents 2d2deea + 520efec commit 105d82a

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

Lib/test/test_clinic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,26 @@ def test_unknown_destination_command(self):
318318
msg = "unknown destination command 'nosuchcommand'"
319319
self.assertIn(msg, out)
320320

321+
def test_no_access_to_members_in_converter_init(self):
322+
out = self.expect_failure("""
323+
/*[python input]
324+
class Custom_converter(CConverter):
325+
converter = "some_c_function"
326+
def converter_init(self):
327+
self.function.noaccess
328+
[python start generated code]*/
329+
/*[clinic input]
330+
module test
331+
test.fn
332+
a: Custom
333+
[clinic start generated code]*/
334+
""")
335+
msg = (
336+
"Stepped on a land mine, trying to access attribute 'noaccess':\n"
337+
"Don't access members of self.function inside converter_init!"
338+
)
339+
self.assertIn(msg, out)
340+
321341

322342
class ClinicGroupPermuterTest(TestCase):
323343
def _test(self, l, m, r, output):

Lib/test/test_ctypes/test_as_parameter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class S8I(Structure):
192192
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
193193

194194
def test_recursive_as_param(self):
195-
class A(object):
195+
class A:
196196
pass
197197

198198
a = A()
@@ -201,15 +201,15 @@ class A(object):
201201
c_int.from_param(a)
202202

203203

204-
class AsParamWrapper(object):
204+
class AsParamWrapper:
205205
def __init__(self, param):
206206
self._as_parameter_ = param
207207

208208
class AsParamWrapperTestCase(BasicWrapTestCase):
209209
wrap = AsParamWrapper
210210

211211

212-
class AsParamPropertyWrapper(object):
212+
class AsParamPropertyWrapper:
213213
def __init__(self, param):
214214
self._param = param
215215

Lib/test/test_ctypes/test_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_unsupported_restype_2(self):
120120
def test_issue_7959(self):
121121
proto = self.functype.__func__(None)
122122

123-
class X(object):
123+
class X:
124124
def func(self): pass
125125
def __init__(self):
126126
self.v = proto(self.func)

Lib/test/test_ctypes/test_numbers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_byref(self):
8686
def test_floats(self):
8787
# c_float and c_double can be created from
8888
# Python int and float
89-
class FloatLike(object):
89+
class FloatLike:
9090
def __float__(self):
9191
return 2.0
9292
f = FloatLike()
@@ -97,15 +97,15 @@ def __float__(self):
9797
self.assertEqual(t(f).value, 2.0)
9898

9999
def test_integers(self):
100-
class FloatLike(object):
100+
class FloatLike:
101101
def __float__(self):
102102
return 2.0
103103
f = FloatLike()
104-
class IntLike(object):
104+
class IntLike:
105105
def __int__(self):
106106
return 2
107107
d = IntLike()
108-
class IndexLike(object):
108+
class IndexLike:
109109
def __index__(self):
110110
return 2
111111
i = IndexLike()

Lib/test/test_ctypes/test_parameters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ def test_noctypes_argtype(self):
157157
# TypeError: has no from_param method
158158
self.assertRaises(TypeError, setattr, func, "argtypes", (object,))
159159

160-
class Adapter(object):
160+
class Adapter:
161161
def from_param(cls, obj):
162162
return None
163163

164164
func.argtypes = (Adapter(),)
165165
self.assertEqual(func(None), None)
166166
self.assertEqual(func(object()), None)
167167

168-
class Adapter(object):
168+
class Adapter:
169169
def from_param(cls, obj):
170170
return obj
171171

@@ -174,7 +174,7 @@ def from_param(cls, obj):
174174
self.assertRaises(ArgumentError, func, object())
175175
self.assertEqual(func(c_void_p(42)), 42)
176176

177-
class Adapter(object):
177+
class Adapter:
178178
def from_param(cls, obj):
179179
raise ValueError(obj)
180180

Python/import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
601601
when an extension is loaded. This includes when it is imported
602602
for the first time.
603603
604-
Here's a summary, using importlib._boostrap._load() as a starting point.
604+
Here's a summary, using importlib._bootstrap._load() as a starting point.
605605
606606
1. importlib._bootstrap._load()
607607
2. _load(): acquire import lock

0 commit comments

Comments
 (0)