-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Description
pycryptodome cannot be imported and used before a python statement "import psutil" which is rather odd!
if not "import psutil", will run into a error like:
[ERROR] org.example.embedding.test.EmbeddingTest.testFail -- Time elapsed: 43.38 s <<< ERROR!
AttributeError: AttributeError: UnknownIdentifierException: Unknown identifier: PyObject_GetBuffer
Java stack trace:
com.oracle.truffle.api.interop.UnknownIdentifierException: Unknown identifier: PyObject_GetBuffer
at <python> <module>(Unknown)
at org.graalvm.polyglot.Context.eval(Context.java:449)
at org.example.embedding.Main.main(Main.java:83)
at org.example.embedding.test.EmbeddingTest.testFail(EmbeddingTest.java:60)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
there is a repo which will reproduces the error
https://github.com/buuuuuuug/pycrypto_graalpy
clone
git clone https://github.com/buuuuuuug/pycrypto_graalpy.git && cd pycrypto_graalpy
versions
mvn --version
Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b)
Maven home: /root/.sdkman/candidates/maven/current
Java version: 25, vendor: Oracle Corporation, runtime: /root/.sdkman/candidates/java/25-graal
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-40-generic", arch: "amd64", family: "unix"
test
mvn test
there are two tests, the first one will run "import psutil" before import Crypto, and it passes!
the second one, will not run "import psutil", and there it fails.
public class EmbeddingTest {
@Test
public void testSuccess() throws IOException {
// success
Main.main(new String[1]);
}
@Test
public void testFail() throws IOException {
// fail
Main.main(new String[0]);
}
}
Metadata
Metadata
Assignees
Labels
No labels