Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f54b02

Browse files
committed
Remove bogus assertions
1 parent f7e6219 commit 8f54b02

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

Lib/test/test_type_params.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,13 @@ def meth(self):
344344
return "base"
345345

346346
class Child(Base):
347-
def meth[T](self) -> T:
347+
# Having int in the annotation ensures the class gets cells for both
348+
# __class__ and __classdict__
349+
def meth[T](self, arg: int) -> T:
348350
return super().meth() + "child"
349351

350352
c = Child()
351-
self.assertEqual(c.meth(), "basechild")
353+
self.assertEqual(c.meth(1), "basechild")
352354

353355

354356
def global_generic_func[T]():

Python/compile.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,7 +2464,6 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno)
24642464
compiler_exit_scope(c);
24652465
return ERROR;
24662466
}
2467-
assert(i == 0);
24682467
ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i);
24692468
ADDOP_I(c, NO_LOCATION, COPY, 1);
24702469
if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store) < 0) {
@@ -2474,8 +2473,6 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno)
24742473
}
24752474
else {
24762475
/* No methods referenced __class__, so just return None */
2477-
assert(PyDict_GET_SIZE(c->u->u_metadata.u_cellvars) ==
2478-
c->u->u_ste->ste_needs_classdict ? 1 : 0);
24792476
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
24802477
}
24812478
ADDOP_IN_SCOPE(c, NO_LOCATION, RETURN_VALUE);

0 commit comments

Comments
 (0)