Retrieve a copy of the dict of a class without the inherited method.
(cls)
| 424 | |
| 425 | |
| 426 | def _extract_class_dict(cls): |
| 427 | """Retrieve a copy of the dict of a class without the inherited method.""" |
| 428 | # Hack to circumvent non-predictable memoization caused by string interning. |
| 429 | # See the inline comment in _class_setstate for details. |
| 430 | clsdict = {"".join(k): cls.__dict__[k] for k in sorted(cls.__dict__)} |
| 431 | |
| 432 | if len(cls.__bases__) == 1: |
| 433 | inherited_dict = cls.__bases__[0].__dict__ |
| 434 | else: |
| 435 | inherited_dict = {} |
| 436 | for base in reversed(cls.__bases__): |
| 437 | inherited_dict.update(base.__dict__) |
| 438 | to_remove = [] |
| 439 | for name, value in clsdict.items(): |
| 440 | try: |
| 441 | base_value = inherited_dict[name] |
| 442 | if value is base_value: |
| 443 | to_remove.append(name) |
| 444 | except KeyError: |
| 445 | pass |
| 446 | for name in to_remove: |
| 447 | clsdict.pop(name) |
| 448 | return clsdict |
| 449 | |
| 450 | |
| 451 | def is_tornado_coroutine(func): |