Skip to content

Commit a79f0f1

Browse files
fangerertimfel
authored andcommitted
Fix style
(cherry picked from commit 900ce81)
1 parent 836b3e7 commit a79f0f1

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import java.io.IOException;
5555
import java.nio.file.LinkOption;
5656

57-
import com.oracle.truffle.api.TruffleFile;
5857
import org.graalvm.shadowed.com.ibm.icu.impl.Punycode;
5958
import org.graalvm.shadowed.com.ibm.icu.text.StringPrepParseException;
6059

@@ -82,6 +81,7 @@
8281
import com.oracle.truffle.api.CompilerDirectives;
8382
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
8483
import com.oracle.truffle.api.CompilerDirectives.ValueType;
84+
import com.oracle.truffle.api.TruffleFile;
8585
import com.oracle.truffle.api.TruffleLanguage.Env;
8686
import com.oracle.truffle.api.TruffleLogger;
8787
import com.oracle.truffle.api.exception.AbstractTruffleException;
@@ -319,8 +319,8 @@ public static Object loadCExtModule(Node location, PythonContext context, Module
319319

320320
// we always need to load the CPython C API (even for HPy modules)
321321
CApiContext cApiContext = CApiContext.ensureCapiWasLoaded(location, context, spec.name, spec.path);
322-
Object library = null;
323-
322+
Object library;
323+
InteropLibrary interopLib;
324324

325325
if (cApiContext.useNativeBackend) {
326326
GraalHPyJNIContext.loadJNIBackend();
@@ -333,27 +333,26 @@ public static Object loadCExtModule(Node location, PythonContext context, Module
333333
try {
334334
Source librarySource = Source.newBuilder(J_NFI_LANGUAGE, loadExpr, "load " + spec.name).build();
335335
library = context.getEnv().parseInternal(librarySource).call();
336+
interopLib = InteropLibrary.getUncached(library);
336337
} catch (PException e) {
337338
throw e;
338339
} catch (AbstractTruffleException e) {
339340
throw new ImportException(CExtContext.wrapJavaException(e, location), spec.name, spec.path, ErrorMessages.CANNOT_LOAD_M, spec.path, e);
340341
}
341342
} else {
342343
library = loadLLVMLibrary(location, context, spec.name, spec.path);
344+
interopLib = InteropLibrary.getUncached(library);
343345
try {
344-
if (InteropLibrary.getUncached(library).getLanguage(library).toString().startsWith("class com.oracle.truffle.nfi")) {
346+
if (interopLib.getLanguage(library).toString().startsWith("class com.oracle.truffle.nfi")) {
345347
throw PRaiseNode.raiseUncached(null, SystemError, ErrorMessages.NO_BITCODE_FOUND, spec.path);
346348
}
347349
} catch (UnsupportedMessageException e) {
348350
throw CompilerDirectives.shouldNotReachHere(e);
349351
}
350352
}
351-
InteropLibrary llvmInteropLib = InteropLibrary.getUncached(library);
352353

353-
// Now, try to detect the C extension's API by looking for the appropriate init
354-
// functions.
355354
try {
356-
return cApiContext.initCApiModule(location, library, spec.getInitFunctionName(), spec, llvmInteropLib, checkFunctionResultNode);
355+
return cApiContext.initCApiModule(location, library, spec.getInitFunctionName(), spec, interopLib, checkFunctionResultNode);
357356
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
358357
throw new ImportException(CExtContext.wrapJavaException(e, location), spec.name, spec.path, ErrorMessages.CANNOT_INITIALIZE_WITH, spec.path, spec.getEncodedName(), "");
359358
}

graalpython/lib-graalpython/modules/standalone/templates/Py2BinLauncher.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ public class Py2BinLauncher {
6666
private static final String PROJ_PREFIX = "/{vfs-proj-prefix}";
6767

6868
public static void main(String[] args) throws IOException {
69-
VirtualFileSystem vfs;
70-
vfs = new VirtualFileSystem(p -> {
71-
String s = p.toString();
72-
return s.endsWith(".so") || s.endsWith(".dylib") || s.endsWith(".pyd");
73-
});
69+
VirtualFileSystem vfs = new VirtualFileSystem(p -> {
70+
String s = p.toString();
71+
return s.endsWith(".so") || s.endsWith(".dylib") || s.endsWith(".pyd");
72+
});
7473
var builder = Context.newBuilder()
7574
.allowExperimentalOptions(true)
7675
.allowAllAccess(true)

0 commit comments

Comments
 (0)