◐ Shell
clean mode source ↗

bpo-34805: Guarantee that __subclasses__() is in definition order. by rhettinger · Pull Request #23844 · python/cpython

Expand Up @@ -4,6 +4,8 @@ import itertools import math import pickle import random import string import sys import types import unittest Expand Down Expand Up @@ -845,6 +847,14 @@ class Module(types.ModuleType, str): self.fail("inheriting from ModuleType and str at the same time " "should fail")
# Issue 34805: Verify that definition order is retained
Comment thread

pablogsal marked this conversation as resolved.

def random_name(): return ''.join(random.choices(string.ascii_letters, k=10)) class A: pass subclasses = [type(random_name(), (A,), {}) for i in range(100)] self.assertEqual(A.__subclasses__(), subclasses)
def test_multiple_inheritance(self): # Testing multiple inheritance... class C(object): Expand Down