Sys unraisablehook#3576
Conversation
|
There are many test cases related to
|
41b4d10 to
7c409b6
Compare
|
@Snowapril could you review this PR? |
|
Isn't the print for https://github.com/python/cpython/blob/main/Python/errors.c#L1336-L1377 assert(PyExceptionClass_Check(exc_type));
PyObject *modulename = PyObject_GetAttr(exc_type, &_Py_ID(__module__));
if (modulename == NULL || !PyUnicode_Check(modulename)) {
Py_XDECREF(modulename);
_PyErr_Clear(tstate);
if (PyFile_WriteString("<unknown>", file) < 0) {
return -1;
}
}
else {
if (!_PyUnicode_Equal(modulename, &_Py_ID(builtins)) &&
!_PyUnicode_Equal(modulename, &_Py_ID(__main__))) {
if (PyFile_WriteObject(modulename, file, Py_PRINT_RAW) < 0) {
Py_DECREF(modulename);
return -1;
}
Py_DECREF(modulename);
if (PyFile_WriteString(".", file) < 0) {
return -1;
}
}
else {
Py_DECREF(modulename);
}
}
PyObject *qualname = PyType_GetQualName((PyTypeObject *)exc_type);
if (qualname == NULL || !PyUnicode_Check(qualname)) {
Py_XDECREF(qualname);
_PyErr_Clear(tstate);
if (PyFile_WriteString("<unknown>", file) < 0) {
return -1;
}
}
else {
if (PyFile_WriteObject(qualname, file, Py_PRINT_RAW) < 0) {
Py_DECREF(qualname);
return -1;
}
Py_DECREF(qualname);
} |
7c409b6 to
fa812e1
Compare
|
thanks, I fixed it based on the code |
coolreader18
left a comment
There was a problem hiding this comment.
Some comments on structseq and other nits
| } | ||
|
|
||
| #[pyfunction] | ||
| fn unraisablehook(unraisable: PyRef<UnraisableHookArgs>, vm: &VirtualMachine) { |
There was a problem hiding this comment.
These are supposed to be the same, (sys.unraisablehook is sys.__unraisablehook__) == True in CPython.
There was a problem hiding this comment.
Still sys.unraisablehook is not sys.__unraisablehook__, but I regard this result as bug of #[pymodule] macro for current version
|
|
||
| #[pyfunction] | ||
| fn __unraisablehook__( | ||
| unraisable: PyRef<UnraisableHookArgs>, |
There was a problem hiding this comment.
e.g. for this (instead of the PyValue thing) you could write a custom TryFromObject for UnraisableHookArgs that just checks if x.isinstance(Self::static_type()) and then extracts the tuple from there.
70179eb to
6dbbfbd
Compare
|
@coolreader18 I splited macro work to #3613 and rebased this PR on it. |
a1f34c7 to
4337cd3
Compare
| Ok(()) | ||
| } | ||
|
|
||
| #[pyattr] |
There was a problem hiding this comment.
@coolreader18 Now they will be the same object
d2370a4 to
bf533c8
Compare
bf533c8 to
ca107ab
Compare
ca107ab to
c564a18
Compare
No description provided.