Skip to content

Commit eea7367

Browse files
committed
Changing how polyglot_arrow is resolved
1 parent 547e73d commit eea7367

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

graalpython/com.oracle.graal.python.frozen/freeze_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
def add_graalpython_core():
103103
lib_graalpython = os.path.join(os.path.dirname(__file__), "..", "lib-graalpython")
104104
l = []
105+
l.append("polyglot.arrow : polyglot.arrow = " + os.path.join(lib_graalpython, "modules/_polyglot_arrow.py"))
105106
for name in [
106107
"modules/_sysconfigdata",
107108
]:

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/FrozenModules.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ private static final class Map {
216216
private static final PythonFrozenModule __PHELLO___HAM_EGGS = new PythonFrozenModule("__PHELLO___HAM_EGGS", "__phello__.ham.eggs", false);
217217
private static final PythonFrozenModule __PHELLO___SPAM = new PythonFrozenModule("__PHELLO___SPAM", "__phello__.spam", false);
218218
private static final PythonFrozenModule FROZEN_ONLY = new PythonFrozenModule("FROZEN_ONLY", null, false);
219+
private static final PythonFrozenModule POLYGLOT_ARROW = new PythonFrozenModule("POLYGLOT_ARROW", null, false);
219220
private static final PythonFrozenModule _SYSCONFIGDATA = new PythonFrozenModule("_SYSCONFIGDATA", null, false);
220221
private static final PythonFrozenModule GRAALPY___GRAALPYTHON__ = new PythonFrozenModule("GRAALPY___GRAALPYTHON__", null, false);
221222
private static final PythonFrozenModule GRAALPY__POLYGLOT = new PythonFrozenModule("GRAALPY__POLYGLOT", null, false);
@@ -591,6 +592,8 @@ public static final PythonFrozenModule lookup(String name) {
591592
return Map.__PHELLO___SPAM;
592593
case "__hello_only__":
593594
return Map.FROZEN_ONLY;
595+
case "polyglot.arrow":
596+
return Map.POLYGLOT_ARROW;
594597
case "_sysconfigdata":
595598
return Map._SYSCONFIGDATA;
596599
case "graalpy.__graalpython__":

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/vector/VectorToArrowArrayNode.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ static ArrowArray doIntVector(Node inliningTarget, Object vector,
7373
snapshot.null_count = (Integer) interopLib.invokeMember(vector, "getNullCount");
7474
snapshot.n_buffers = (Integer) interopLib.invokeMember(vector, "getExportedCDataBufferCount");
7575
if (snapshot.n_buffers != 2) {
76-
// we expect only two buffers (validity and value buffer)
77-
throw CompilerDirectives.shouldNotReachHere();
76+
throw CompilerDirectives.shouldNotReachHere("We expect that Vector implementation to has just 2 buffers, those are validity buffer and value buffer. This should never happen unless arrow changes internally");
7877
}
7978
snapshot.buffers = unsafe.allocateMemory(2 * POINTER_SIZE);
8079
long validityPointer = (long) interopLib.invokeMember(vector, "getValidityBufferAddress");
@@ -85,7 +84,7 @@ static ArrowArray doIntVector(Node inliningTarget, Object vector,
8584

8685
return ArrowArray.allocateFromSnapshot(snapshot);
8786
} catch (Exception e) {
88-
throw CompilerDirectives.shouldNotReachHere();
87+
throw CompilerDirectives.shouldNotReachHere("Unable to convert vector to arrow array. Error: " + e.getMessage());
8988
}
9089
}
9190

graalpython/lib-graalpython/_polyglot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ def _struct_time_tz(st: time.struct_time):
146146
# loading arrow structures on demand
147147
def __getattr__(name):
148148
if name == "arrow":
149-
from modules import _polyglot_arrow
149+
import _polyglot_arrow
150150
setattr(polyglot, "arrow", _polyglot_arrow)
151151
return _polyglot_arrow
152152
raise AttributeError(f"module 'polyglot' has no attribute '{name}'")
153153

154154
setattr(polyglot, "__getattr__", __getattr__)
155+
setattr(polyglot, "__path__", ".")
155156

156157
# example extending time.struct_time using the decorator wrapper
157158
#

0 commit comments

Comments
 (0)