Skip to content

Commit bd98577

Browse files
committed
[GR-40129] Avoid pytest false negatives on interop exceptions
PullRequest: graalpython/2374
2 parents 8ab868d + cc02e83 commit bd98577

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,11 +2867,10 @@ private PException popExceptionState(Object[] arguments, Object savedException,
28672867
PException localException = null;
28682868
if (savedException instanceof PException) {
28692869
localException = (PException) savedException;
2870+
PArguments.setException(arguments, localException);
2871+
} else if (savedException == null) {
2872+
PArguments.setException(arguments, outerException);
28702873
}
2871-
if (savedException == null) {
2872-
savedException = outerException;
2873-
}
2874-
PArguments.setException(arguments, (PException) savedException);
28752874
return localException;
28762875
}
28772876

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import com.oracle.graal.python.nodes.PNodeWithContext;
6060
import com.oracle.graal.python.nodes.truffle.PythonTypes;
6161
import com.oracle.graal.python.runtime.exception.PException;
62-
import com.oracle.truffle.api.CompilerDirectives;
6362
import com.oracle.truffle.api.dsl.Bind;
6463
import com.oracle.truffle.api.dsl.Cached;
6564
import com.oracle.truffle.api.dsl.Fallback;
@@ -68,9 +67,6 @@
6867
import com.oracle.truffle.api.dsl.Specialization;
6968
import com.oracle.truffle.api.dsl.TypeSystemReference;
7069
import com.oracle.truffle.api.exception.AbstractTruffleException;
71-
import com.oracle.truffle.api.interop.ExceptionType;
72-
import com.oracle.truffle.api.interop.InteropLibrary;
73-
import com.oracle.truffle.api.interop.UnsupportedMessageException;
7470
import com.oracle.truffle.api.library.CachedLibrary;
7571
import com.oracle.truffle.api.object.DynamicObjectLibrary;
7672
import com.oracle.truffle.api.object.Shape;
@@ -197,9 +193,8 @@ static Object getNativeVoidPtr(@SuppressWarnings("unused") PythonNativeVoidPtr o
197193
return PythonBuiltinClassType.PInt;
198194
}
199195

200-
@Specialization(guards = "isForeignRuntimeException(object, lib)")
201-
static Object getTruffleException(@SuppressWarnings("unused") AbstractTruffleException object,
202-
@SuppressWarnings("unused") @CachedLibrary(limit = "3") InteropLibrary lib) {
196+
@Specialization
197+
static Object getTruffleException(@SuppressWarnings("unused") AbstractTruffleException object) {
203198
/*
204199
* Special case: if Python code asks for the class of a foreign exception, we return a
205200
* Python type that inherits from BaseException. We do this because Python users usually
@@ -217,12 +212,4 @@ static Object getForeign(@SuppressWarnings("unused") Object object) {
217212
protected static boolean hasInitialClass(Shape shape) {
218213
return (shape.getFlags() & PythonObject.CLASS_CHANGED_FLAG) == 0;
219214
}
220-
221-
protected static boolean isForeignRuntimeException(AbstractTruffleException e, InteropLibrary lib) {
222-
try {
223-
return lib.isException(e) && lib.getExceptionType(e) == ExceptionType.RUNTIME_ERROR;
224-
} catch (UnsupportedMessageException ex) {
225-
throw CompilerDirectives.shouldNotReachHere(ex);
226-
}
227-
}
228215
}

graalpython/lib-graalpython/modules/hpy/test/test_hpycontextvar.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
2323

24+
import pytest
2425
from .support import HPyTest
2526

2627

2728
class TestContextVar(HPyTest):
29+
@pytest.mark.skip(reason="GR-40178")
2830
def test_ContextVar_basics(self):
2931
mod = self.make_module("""
3032
HPyDef_METH(create_ctxvar, "create_ctxvar", create_ctxvar_impl, HPyFunc_O)

graalpython/lib-graalpython/modules/hpy/test/test_hpyerr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
2323

24+
import pytest
2425
from .support import HPyTest, SUPPORTS_SYS_EXECUTABLE, trampoline
2526

2627

@@ -169,6 +170,7 @@ def test_HPyErr_SetFromErrno(self):
169170

170171
assert err.value.errno == errno.EINVAL
171172

173+
@pytest.mark.skip(reason="GR-40178")
172174
def test_HPyErr_SetFromErrnoWithFilenameObjects(self):
173175
import pytest
174176
import errno
@@ -206,6 +208,7 @@ def test_HPyErr_SetFromErrnoWithFilenameObjects(self):
206208
assert err.value.filename == file1
207209
assert err.value.filename2 == file2
208210

211+
@pytest.mark.skip(reason="GR-40178")
209212
def test_HPyErr_SetFromErrnoWithFilename(self):
210213
import pytest
211214
import errno

graalpython/lib-graalpython/modules/hpy/test/test_hpyunicode.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
# SOFTWARE.
2424

25+
import pytest
2526
from .support import HPyTest
2627

2728
class TestUnicode(HPyTest):
@@ -162,6 +163,7 @@ def test_AsUTF8AndSize(self):
162163
assert mod.g(b'A'.decode('utf-8')) == ord('A')
163164
assert mod.g(b'A\0'.decode('utf-8')) == ord('A')
164165

166+
@pytest.mark.skip(reason="GR-40178")
165167
def test_DecodeLatin1(self):
166168
mod = self.make_module("""
167169
HPyDef_METH(f, "f", f_impl, HPyFunc_O)

0 commit comments

Comments
 (0)