Skip to content

v0.0.342: super(C, inst) + metaclass __instancecheck__#263

Merged
tamnd merged 1 commit into
mainfrom
feat/v0.0.342-super-metaclass-instancecheck
Apr 29, 2026
Merged

v0.0.342: super(C, inst) + metaclass __instancecheck__#263
tamnd merged 1 commit into
mainfrom
feat/v0.0.342-super-metaclass-instancecheck

Conversation

@tamnd

@tamnd tamnd commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • super(C, inst) now returns an *object.Super proxy (was a stub returning None); zero-arg super() also rerouted through the builtin when the compiler skips LOAD_SUPER_ATTR.
  • isinstance / issubclass consult metaclass.__instancecheck__ / __subclasscheck__ before MRO; Class.Metaclass populated from metaclass= kwarg or inherited via base.
  • Closes B7 and C3 from the v0.1.0 audit. Spec: notes/Spec/1500/1536_goipy_v0042_super_metaclass.md. Fixture: internal/testdata/342_super_metaclass.py.

Test plan

  • go test ./... -timeout 600s green
  • Fixture 342 matches CPython
  • No regression on existing super / isinstance / abc fixtures

Closes B7 and C3 from the v0.1.0 audit.

Two-arg super(C, inst) used to return None (the builtin was a stub),
breaking metaclass machinery and __init_subclass__ patterns. Now returns
an *object.Super proxy that getAttr resolves via lookupAfter +
bindDescriptor. Zero-arg super() is also rerouted through the builtin
when the compiler emits LOAD_GLOBAL super; CALL 0 instead of the
optimized LOAD_SUPER_ATTR -- happens when the module also calls
super(C, inst) explicitly somewhere, which disables the optimization
file-wide.

isinstance/issubclass now consult metaclass.__instancecheck__ /
__subclasscheck__ before walking the MRO. Class.Metaclass is set when a
class body uses metaclass= or inherits one from a base. ABCMeta keeps
working through its existing ABCCheck callback; this is purely additive.

Spec at notes/Spec/1500/1536_goipy_v0042_super_metaclass.md.
@tamnd tamnd merged commit 0563f7d into main Apr 29, 2026
1 check passed
@tamnd tamnd deleted the feat/v0.0.342-super-metaclass-instancecheck branch April 29, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant