Skip to content
Merged
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
26 changes: 17 additions & 9 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2479,22 +2479,30 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds)
}
assert(sw_info);
#ifdef WORDS_BIGENDIAN
PyObject_SetAttrString(self, "__ctype_le__", swapped);
PyObject_SetAttrString(self, "__ctype_be__", self);
PyObject_SetAttrString(swapped, "__ctype_be__", self);
PyObject_SetAttrString(swapped, "__ctype_le__", swapped);
if (PyObject_SetAttrString(self, "__ctype_le__", swapped) < 0 ||
PyObject_SetAttrString(self, "__ctype_be__", self) < 0 ||
PyObject_SetAttrString(swapped, "__ctype_be__", self) < 0 ||
PyObject_SetAttrString(swapped, "__ctype_le__", swapped) < 0)
{
Py_DECREF(swapped);
return -1;
}
/* We are creating the type for the OTHER endian */
sw_info->format = _ctypes_alloc_format_string("<", stginfo->format+1);
#else
PyObject_SetAttrString(self, "__ctype_be__", swapped);
PyObject_SetAttrString(self, "__ctype_le__", self);
PyObject_SetAttrString(swapped, "__ctype_le__", self);
PyObject_SetAttrString(swapped, "__ctype_be__", swapped);
if (PyObject_SetAttrString(self, "__ctype_be__", swapped) < 0 ||
PyObject_SetAttrString(self, "__ctype_le__", self) < 0 ||
PyObject_SetAttrString(swapped, "__ctype_le__", self) < 0 ||
PyObject_SetAttrString(swapped, "__ctype_be__", swapped) < 0)
{
Py_DECREF(swapped);
return -1;
}
/* We are creating the type for the OTHER endian */
sw_info->format = _ctypes_alloc_format_string(">", stginfo->format+1);
Comment thread
StanFromIreland marked this conversation as resolved.
#endif
Py_DECREF(swapped);
if (PyErr_Occurred()) {
if (sw_info->format == NULL) {
return -1;
}
};
Expand Down
2 changes: 1 addition & 1 deletion Modules/_interpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ _channelid_shared(PyThreadState *tstate, PyObject *obj, _PyXIData_t *data)
if (st == NULL) {
return -1;
}
if (!PyObject_IsInstance(obj, (PyObject *)st->ChannelIDType)) {
if (!PyObject_TypeCheck(obj, st->ChannelIDType)) {
PyErr_Format(PyExc_TypeError,
"'_id' attribute must be an %N object, not %T",
st->ChannelIDType, obj);
Expand Down
20 changes: 16 additions & 4 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3211,8 +3211,14 @@ init_sys_streams(PyThreadState *tstate)
config->stdio_errors);
if (std == NULL)
goto error;
PySys_SetObject("__stdin__", std);
_PySys_SetAttr(&_Py_ID(stdin), std);
if (PySys_SetObject("__stdin__", std) < 0) {
Py_DECREF(std);
goto error;
}
if (_PySys_SetAttr(&_Py_ID(stdin), std) < 0) {
Py_DECREF(std);
goto error;
}
Py_DECREF(std);

/* Set sys.stdout */
Expand All @@ -3222,8 +3228,14 @@ init_sys_streams(PyThreadState *tstate)
config->stdio_errors);
if (std == NULL)
goto error;
PySys_SetObject("__stdout__", std);
_PySys_SetAttr(&_Py_ID(stdout), std);
if (PySys_SetObject("__stdout__", std) < 0) {
Py_DECREF(std);
goto error;
}
if (_PySys_SetAttr(&_Py_ID(stdout), std) < 0) {
Py_DECREF(std);
goto error;
}
Py_DECREF(std);

#if 1 /* Disable this if you have trouble debugging bootstrap stuff */
Expand Down
8 changes: 6 additions & 2 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4380,8 +4380,12 @@ _PySys_Create(PyThreadState *tstate, PyObject **sysmod_p)
PyUnstable_Module_SetGIL(sysmod, Py_MOD_GIL_NOT_USED);
#endif

PyModule_AddIntMacro(sysmod, EXIT_SUCCESS);
PyModule_AddIntMacro(sysmod, EXIT_FAILURE);
if (PyModule_AddIntMacro(sysmod, EXIT_SUCCESS) < 0) {
goto error;
}
if (PyModule_AddIntMacro(sysmod, EXIT_FAILURE) < 0) {
goto error;
}

PyObject *sysdict = PyModule_GetDict(sysmod);
if (sysdict == NULL) {
Expand Down
Loading