Overriding constructors for classes inheriting from Java
@timfel 已经在做这个了。
开始于 2025年1月20日。
评估
这个 Issue 还没有评估数据。
描述
As of the latest version (23.1.0), GraalPy does not support overriding constructors for Python classes that inherit from Java.
The example below throws an error when we try to create a custom Exception wrapper in Python:
package my.pack;
import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.Context;
public class Main {
static Context context = Context.newBuilder().allowAllAccess(true).build();
static Value clz;
public static void main(String[] args) {
context.eval("python", """
import java
class ParseException(java.lang.Exception):
def __init__(self, message):
self.__super__(message)
""");
clz = context.getBindings("python").getMember("ParseException");
Value obj = clz.newInstance("Hello from Java");
}
}
Result
// error
Exception in thread "main" TypeError: ParseException.__init__() missing 1 required positional argument: 'message'
at org.graalvm.sdk/org.graalvm.polyglot.Value.newInstance(Value.java:933)
at my.pack.Main.main(Main.java:18)
- 主要语言
- Python
- 星标
- 1.6k
- 派生
- 155
- 平均合并
- 7 小时 45 分钟
- 30 天内合并 PR
- 47
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
oracle/graalpython 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
oracle/graalpython#1105 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
oracle/graalpython#1102 ·
-
bug
难度 5/5 一周以上 新手友好度 35/100
oracle/graalpython#1169 ·
-
bug
难度 3/5 1-2 天 新手友好度 74/100
oracle/graalpython#1133 ·
-
bug
难度 3/5 1-2 天 新手友好度 68/100
oracle/graalpython#1112 ·
查看 oracle/graalpython 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100