Skip to content

PyCColorDialog.SetCustomColors returns error without setting exception #2579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Avasam opened this issue Apr 24, 2025 · 0 comments
Open

PyCColorDialog.SetCustomColors returns error without setting exception #2579

Avasam opened this issue Apr 24, 2025 · 0 comments
Labels

Comments

@Avasam
Copy link
Collaborator

Avasam commented Apr 24, 2025

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

@Avasam Avasam added the bug label Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant