From 661d726c7448441da58695f4e254e846ea7a78d5 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Sat, 3 Oct 2026 09:09:40 +0900 Subject: [PATCH] Fix: Serve a Kotlin object as a namespace when the binder lists it itself python-multiplatform #35 (PR #51, develop d6d39787) lists a Kotlin object's sub-package in its parent module's dir() and exposes it as an attribute. The re-export's name table therefore found Arrangement directly and handed back the binder's raw module, whose function is spacedBy: Arrangement.spaced_by failed and dir() showed Kotlin names. A Kotlin module reached through the table is now wrapped as a KotlinObject, the same as the import fallback does for an older binder. defect fixed: unwrapped Kotlin objects against python-multiplatform d6d39787. Red: against d6d39787, 3 tests failed (ObjectNamespaces x2, the object-function stub test). After: 144 passed against d6d39787 (exported read-only) and the sibling checkout. No test added: the existing ones caught it. Refs #41 --- pythonx/compose/_reexport.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pythonx/compose/_reexport.py b/pythonx/compose/_reexport.py index 834ff1c..58c128d 100644 --- a/pythonx/compose/_reexport.py +++ b/pythonx/compose/_reexport.py @@ -43,6 +43,7 @@ import inspect import re import sys +import types import weakref from functools import lru_cache from pathlib import Path @@ -214,6 +215,10 @@ def __repr__(self): def _pythonic(value, name): + if isinstance(value, types.ModuleType): + # A Kotlin object served as a sub-package. Since python-multiplatform #35 the binder lists it + # and exposes it as an attribute of its parent, so the name table reaches it directly. + return KotlinObject(value) if isinstance(value, type) or not callable(value): return value return PythonicFunction(value, name)