Describe the bug
Summary
str() (and %-formatting) of a host java.util.Date from Python throws NullPointerException: Cannot read field "utc" because "moduleData" is null in the datetime builtin module. Works on 25.0.4, broken on 25.1.3 and 25.2.4.
Environment
- GraalPy/polyglot python: 25.1.3 and 25.2.4 (both reproduce); last known good 25.0.4
- JDK 25 (25+37-LTS), macOS
Operating system
macOS
CPU architecture
ARM64
GraalPy version
25.2.4
JDK version
25
Context configuration
Context.Builder builder = Context.newBuilder().allowAllAccess(true);
try (Context context = builder.build()) {
context.initialize("python");
}
try (Context context = builder.build()) {
Value bindings = context.getBindings("python");
bindings.putMember("date", new java.util.Date());
context.eval("python", "str(date)").as(Object.class);
}
Steps to reproduce
Running the code above on 25.0.4 the code succeeds, on 25.1.3+ the code throws an exception.
Expected behavior
That the UTC is found.
Stack trace
org.graalvm.polyglot.PolyglotException: java.lang.NullPointerException: Cannot read field "utc" because "moduleData" is null
at com.oracle.graal.python.builtins.modules.datetime.DatetimeModuleBuiltins.getUtcTimeZone(DatetimeModuleBuiltins.java:357)
at com.oracle.graal.python.builtins.modules.datetime.TimeZoneNodes$NewNode.newTimezone(TimeZoneNodes.java:122)
at com.oracle.graal.python.builtins.modules.datetime.TemporalValueNodes.toFixedOffsetTimeZone(TemporalValueNodes.java:257)
at com.oracle.graal.python.builtins.modules.datetime.TemporalValueNodes.toPythonTzInfo(TemporalValueNodes.java:236)
at com.oracle.graal.python.builtins.modules.datetime.DateTimeNodes$TzInfoNode.getTzInfo(DateTimeNodes.java:392)
at com.oracle.graal.python.builtins.modules.datetime.DateTimeBuiltins$IsoFormatNode.isoFormat(DateTimeBuiltins.java:2328)
...
at com.oracle.graal.python.builtins.modules.datetime.DateTimeBuiltins$StrNode.str(DateTimeBuiltins.java:397)
at <python>.<module>(Unnamed:1)
at org.graalvm.polyglot.Context.eval(Context.java:449)
Additional context
No response
Describe the bug
Summary
str() (and %-formatting) of a host java.util.Date from Python throws NullPointerException: Cannot read field "utc" because "moduleData" is null in the datetime builtin module. Works on 25.0.4, broken on 25.1.3 and 25.2.4.
Environment
Operating system
macOS
CPU architecture
ARM64
GraalPy version
25.2.4
JDK version
25
Context configuration
Steps to reproduce
Running the code above on 25.0.4 the code succeeds, on 25.1.3+ the code throws an exception.
Expected behavior
That the UTC is found.
Stack trace
Additional context
No response