Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92c943b

Browse files
committed
fix bad first arg
1 parent9384106 commit92c943b

File tree

3 files changed

+233
-227
lines changed

3 files changed

+233
-227
lines changed

‎Lib/test/test_super.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ def method(self):
385385
withself.assertRaisesRegex(AttributeError,"'super' object has no attribute 'msg'"):
386386
C().method()
387387

388+
deftest_bad_first_arg(self):
389+
classC:
390+
defmethod(self):
391+
returnsuper(1,self).method()
392+
393+
withself.assertRaisesRegex(TypeError,"argument 1 must be a type"):
394+
C().method()
395+
388396

389397
if__name__=="__main__":
390398
unittest.main()

‎Python/bytecodes.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,10 +1556,9 @@ dummy_func(
15561556

15571557
inst(LOAD_SUPER_ATTR, (global_super,class,self--res2if (oparg&1),res)) {
15581558
PyObject*name=GETITEM(frame->f_code->co_names,oparg >>2);
1559-
if (global_super== (PyObject*)&PySuper_Type) {
1559+
if (global_super== (PyObject*)&PySuper_Type&&PyType_Check(class)) {
15601560
intmeth_found=0;
15611561
Py_DECREF(global_super);
1562-
assert(PyType_Check(class));
15631562
res=_PySuper_Lookup((PyTypeObject*)class,self,name,oparg&1 ?&meth_found :NULL);
15641563
Py_DECREF(class);
15651564
if (res==NULL) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp