Skip to content

Commit 3da27a5

Browse files
committed
clean up PR
1 parent cd6d3ac commit 3da27a5

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

graalpython/com.oracle.graal.python.cext/src/errors.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) {
158158
}
159159

160160
void PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb) {
161-
// TODO (tfel): do we have to?
161+
// (tfel): nothing to do here from our side, the exception is already
162+
// reified
162163
return;
163164
}
164165

graalpython/com.oracle.graal.python.cext/src/longobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ PyObject * PyLong_FromSize_t(size_t n) {
133133
return PyLong_FromUnsignedLongLong(n);
134134
}
135135

136+
// partially taken from CPython 3.7.0 "Objects/longobject.c"
136137
PyObject * PyLong_FromString(const char* inputStr, char** pend, int base) {
137138
int negative = 0, error_if_nonzero = 0;
138139
char* str = (char*)inputStr;

graalpython/com.oracle.graal.python.cext/src/methodobject.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
4343
PyTypeObject PyCFunction_Type = PY_TRUFFLE_TYPE("builtin_function_or_method", &PyType_Type, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, sizeof(PyCFunctionObject));
4444

4545
PyObject* PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) {
46-
PyObject* func = UPCALL_CEXT_O("PyCFunction_NewEx",
47-
polyglot_from_string((const char*)(ml->ml_name), SRC_CS),
48-
ml->ml_meth,
49-
get_method_flags_cwrapper(ml->ml_flags),
50-
get_method_flags_wrapper(ml->ml_flags),
51-
polyglot_from_string((const char*)(ml->ml_doc ? ml->ml_doc : ""), SRC_CS));
52-
/* TODO: are the below fields required?
53-
* ((PyCFunctionObject*)func)->m_self = self;
54-
* ((PyCFunctionObject*)func)->m_module = module;
55-
* ((PyCFunctionObject*)func)->m_ml = ml;
56-
*/
57-
return func;
46+
PyObject* func = to_sulong(polyglot_invoke(PY_TRUFFLE_CEXT,
47+
"PyCFunction_NewEx",
48+
polyglot_from_string((const char*)(ml->ml_name), SRC_CS),
49+
ml->ml_meth,
50+
get_method_flags_cwrapper(ml->ml_flags),
51+
get_method_flags_wrapper(ml->ml_flags),
52+
polyglot_from_string((const char*)(ml->ml_doc ? ml->ml_doc : ""), SRC_CS)));
53+
if (func == ERROR_MARKER) {
54+
return NULL;
55+
} else {
56+
return func;
57+
}
5858
}

graalpython/com.oracle.graal.python.cext/src/typeobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,5 +423,6 @@ int PyType_Ready(PyTypeObject* cls) {
423423
}
424424

425425
void PyType_Modified(PyTypeObject* type) {
426-
// TODO: (tfel) what needs to be done?
426+
// (tfel) I don't think we have to do anything here, since we track MRO
427+
// changes separately, anyway
427428
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.oracle.truffle.api.Truffle;
5959
import com.oracle.truffle.api.TruffleFile;
6060
import com.oracle.truffle.api.TruffleLanguage;
61+
import com.oracle.truffle.api.TruffleLogger;
6162
import com.oracle.truffle.api.debug.DebuggerTags;
6263
import com.oracle.truffle.api.frame.Frame;
6364
import com.oracle.truffle.api.frame.MaterializedFrame;
@@ -384,4 +385,8 @@ public static PythonCore getCore() {
384385
PythonCore core = getCurrentLanguage(PythonLanguage.class).sharedCore;
385386
return core != null ? core : getContext().getCore();
386387
}
388+
389+
public static TruffleLogger getLogger() {
390+
return TruffleLogger.getLogger(ID, PythonLanguage.class);
391+
}
387392
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
*/
3939
package com.oracle.graal.python.builtins.objects.cext;
4040

41+
import java.util.logging.Level;
42+
4143
import com.oracle.graal.python.PythonLanguage;
4244
import com.oracle.graal.python.builtins.objects.PNone;
4345
import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
@@ -413,7 +415,7 @@ Object doGeneric(Object object, String key) {
413415
if (object instanceof PythonAbstractObject) {
414416
PythonObjectNativeWrapper nativeWrapper = ((PythonAbstractObject) object).getNativeWrapper();
415417
assert nativeWrapper != null;
416-
System.err.println("[python] read of native member " + key);
418+
PythonLanguage.getLogger().log(Level.WARNING, "read of Python struct native member", key);
417419
return getGetItemNode().execute(nativeWrapper.getNativeMemberStore(), key);
418420
}
419421
throw UnknownIdentifierException.raise(key);
@@ -532,7 +534,7 @@ Object doGeneric(Object object, String key, Object value) {
532534
if (object instanceof PythonAbstractObject) {
533535
PythonObjectNativeWrapper nativeWrapper = ((PythonAbstractObject) object).getNativeWrapper();
534536
assert nativeWrapper != null;
535-
System.err.println("[python] write of native member " + key);
537+
PythonLanguage.getLogger().log(Level.WARNING, "write of Python struct native member", key);
536538
getSetItemNode().execute(null, nativeWrapper.createNativeMemberStore(), key, value);
537539
return value;
538540
}

0 commit comments

Comments
 (0)