-
Notifications
You must be signed in to change notification settings - Fork 842
Open
Labels
Description
For all bugs, please provide the following information:
Expected behavior and actual behavior
Calling SetCustomColors
should raise a descriptive exception, namely: TypeError: The argument must be a sequence of integers of length 1-16
. But instead you get SystemError: error return without exception set
.
pywin32/Pythonwin/win32dlg.cpp
Lines 1292 to 1309 in 8258348
if (PyErr_Occurred() || len <= 0 || len > 16) { | |
PyErr_Clear(); | |
PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of integers of length 1-16"); | |
return NULL; | |
} | |
CColorDialog *pDlg = GetColorDialog(self); | |
if (!pDlg) | |
return NULL; | |
for (int i = 0; i < len; i++) { | |
PyObject *obInt = NULL; | |
PyObject *ob = PySequence_GetItem(obCols, i); | |
if (ob != NULL) | |
obInt = PyNumber_Long(ob); | |
if (obInt == NULL) { | |
Py_XDECREF(ob); | |
PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of integers of length 1-16"); | |
return NULL; | |
} |
Steps to reproduce the problem
import win32ui
win32ui.CreateColorDialog(0, 0).SetCustomColors() # SystemError: error return without exception set
win32ui.CreateColorDialog(0, 0).SetCustomColors([]) # SystemError: error return without exception set
win32ui.CreateColorDialog(0, 0).SetCustomColors([0]) # OK
win32ui.CreateColorDialog(0, 0).SetCustomColors((0,0)) # OK
win32ui.CreateColorDialog(0, 0).SetCustomColors((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)) # SystemError: error return without exception set
System information
Python version and distribution: 3.10.11
pywin32 version: 310
Windows Version: 10.0.19045 Build 19045
DLL locations: N/A