Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -44,6 +44,7 @@
import static com.oracle.graal.python.nodes.BuiltinNames.J_FORMATTER_PARSER;
import static com.oracle.graal.python.nodes.BuiltinNames.J__STRING;

import java.util.ArrayList;
import java.util.List;

import com.oracle.graal.python.PythonLanguage;
Expand Down Expand Up @@ -87,7 +88,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
PSequenceIterator formatterParser(VirtualFrame frame, TruffleString self,
@Cached("createFor($node)") BoundaryCallData boundaryCallData) {
TemplateFormatter formatter = new TemplateFormatter(self);
List<Object[]> parserList;
ArrayList<Object[]> parserList;
PythonContext context = PythonContext.get(this);
PythonLanguage language = context.getLanguage(this);
Object state = ExecutionContext.BoundaryCallContext.enter(frame, language, context, boundaryCallData);
Expand All @@ -100,7 +101,7 @@ PSequenceIterator formatterParser(VirtualFrame frame, TruffleString self,
}
}

private static PSequenceIterator parserListToIterator(List<Object[]> parserList, PythonLanguage language) {
private static PSequenceIterator parserListToIterator(ArrayList<Object[]> parserList, PythonLanguage language) {
Object[] tuples = new Object[parserList.size()];
for (int i = 0; i < tuples.length; i++) {
tuples[i] = PFactory.createTuple(language, parserList.get(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,18 @@ static Object lastGroup(PMatch self,
return PNone.NONE;
}

for (Map.Entry<String, Object> entry : self.pattern.groupToIndexMap.entrySet()) {
String name = getLastGroupName(self.pattern.groupToIndexMap, groupIndex);
if (name != null) {
return fromJavaStringNode.execute(name, TS_ENCODING);
}

// the last matched group does not have a name
return PNone.NONE;
}

@TruffleBoundary
private static String getLastGroupName(LinkedHashMap<String, Object> groupToIndexMap, int groupIndex) {
for (Map.Entry<String, Object> entry : groupToIndexMap.entrySet()) {
Object value = entry.getValue();

if (!(value instanceof Integer valueInteger)) {
Expand All @@ -606,13 +617,10 @@ static Object lastGroup(PMatch self,

if (valueInteger == groupIndex) {
// a named group found
String name = entry.getKey();
return fromJavaStringNode.execute(name, TS_ENCODING);
return entry.getKey();
}
}

// the last matched group does not have a name
return PNone.NONE;
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -204,7 +204,7 @@ abstract static class SimpleNamespaceReprNode extends PythonUnaryBuiltinNode {
@CompilerDirectives.ValueType
protected static final class NSReprState {
private final HashingStorage dictStorage;
private final List<Pair<TruffleString, TruffleString>> items;
private final ArrayList<Pair<TruffleString, TruffleString>> items;

@CompilerDirectives.TruffleBoundary
NSReprState(HashingStorage dictStorage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import com.oracle.graal.python.builtins.modules.BuiltinFunctions.FormatNode;
import com.oracle.graal.python.builtins.modules.SysModuleBuiltins;
Expand Down Expand Up @@ -91,7 +90,7 @@ public final class TemplateFormatter {
private String empty;
private Object[] args;
private Object keywords;
private List<Object[]> parserList = null;
private ArrayList<Object[]> parserList = null;
private int autoNumbering;
private int autoNumberingState;

Expand Down Expand Up @@ -411,9 +410,9 @@ private Object renderField(Node node, int start, int end, boolean recursive, int

public static class FieldNameSplitResult {
public Object first;
public List<Object[]> parserList;
public ArrayList<Object[]> parserList;

public FieldNameSplitResult(Object first, List<Object[]> parserList) {
public FieldNameSplitResult(Object first, ArrayList<Object[]> parserList) {
this.first = first;
this.parserList = parserList;
}
Expand Down Expand Up @@ -467,7 +466,7 @@ private static Object convert(Node node, Object obj, char conversion) {
}

@TruffleBoundary
public List<Object[]> formatterParser(Node node) {
public ArrayList<Object[]> formatterParser(Node node) {
this.parserList = new ArrayList<>();
this.lastEnd = 0;
buildString(node, 0, this.template.length(), 2, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ public static AddrInfoCursorLibrary getUncached() {
* Exception that indicates and error while executing
* {@link #getaddrinfo(Object, Object, Object, int, int, int, int)}.
*/
public static class GetAddrInfoException extends Exception {
public static final class GetAddrInfoException extends Exception {

private static final long serialVersionUID = 3013253817849329391L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public Thread getOwner() {
@CompilationFinal private long perfCounterStart = System.nanoTime();

public static final String CHILD_CONTEXT_DATA = "childContextData";
@CompilationFinal private List<Integer> childContextFDs;
@CompilationFinal private ArrayList<Integer> childContextFDs;
private final ChildContextData childContextData;
private final SharedMultiprocessingData sharedMultiprocessingData;

Expand Down Expand Up @@ -1241,7 +1241,7 @@ private static void start(Thread thread) {
thread.start();
}

public synchronized List<Integer> getChildContextFDs() {
public synchronized ArrayList<Integer> getChildContextFDs() {
if (childContextFDs == null) {
childContextFDs = new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,16 @@ public static PException fromExceptionInfo(Object pythonException, boolean withJ
@Override
public String getMessage() {
if (message == null) {
return pythonException.toString();
return getPythonExceptionString();
}
return message;
}

@TruffleBoundary
private String getPythonExceptionString() {
return pythonException.toString();
}

public void materializeMessage() {
if (message == null) {
message = ExceptionUtils.getExceptionMessage(pythonException);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -103,6 +103,7 @@ boolean hasExceptionMessage() {
}

@ExportMessage
@TruffleBoundary
String getExceptionMessage() {
return getMessage();
}
Expand Down
Loading