Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't assume Uproot is in global scope in TPython::Eval #927

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/uproot/pyroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ class _Uproot_buffer_sizer : public TObject {

char* _uproot_TMessage_reallocate(char* buffer, size_t newsize, size_t oldsize) {
_Uproot_buffer_sizer* ptr = reinterpret_cast<_Uproot_buffer_sizer*>(
(void*)TPython::Eval("uproot.pyroot.pyroot_to_buffer.sizer")
(void*)TPython::Eval("__import__('uproot').pyroot.pyroot_to_buffer.sizer")
);
ptr->buffer = reinterpret_cast<size_t>(buffer);
ptr->newsize = newsize;
ptr->oldsize = oldsize;

TPython::Exec("uproot.pyroot.pyroot_to_buffer.reallocate()");
TPython::Exec("__import__('uproot').pyroot.pyroot_to_buffer.reallocate()");

TPyReturn out = TPython::Eval("uproot.pyroot.pyroot_to_buffer.buffer.ctypes.data");
TPyReturn out = TPython::Eval("__import__('uproot').pyroot.pyroot_to_buffer.buffer.ctypes.data");
return reinterpret_cast<char*>((size_t)out);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE

import random
import string

import pytest

ROOT = pytest.importorskip("ROOT")


def test():
name = "".join(random.choices(string.ascii_lowercase, k=10))
h = ROOT.TProfile3D()
assert __import__("uproot").from_pyroot(h).values().shape == (1, 1, 1)
Loading