Overriding constructors for classes inheriting from Java
オープン
@timfel がすでに取り組んでいます。
2025年1月20日 から。
- 主要言語
- Python
- スター
- 1.6k
- フォーク
- 155
- 平均マージ
- 9時間 42分
- マージ済み PR(30日)
- 36
説明
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)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。