Skip to content

Commit

Permalink
Small macro replace
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiFati committed Mar 17, 2024
1 parent ea4f624 commit e325b62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion win32/src/PyWinTypes.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extern PYWINTYPES_EXPORT BOOL PyWin_RegisterErrorMessageModule(DWORD first, DWOR
extern PYWINTYPES_EXPORT HINSTANCE PyWin_GetErrorMessageModule(DWORD err);

/* A global function that sets an API style error (ie, (code, fn, errTest)) */
PYWINTYPES_EXPORT PyObject *PyWin_SetAPIError(char *fnName, long err = 0);
PYWINTYPES_EXPORT PyObject *PyWin_SetAPIError(char *fnName, long err = ERROR_SUCCESS);

// A PyWin_SetAPIError variant that returns None (Py_None) on success.
PYWINTYPES_EXPORT PyObject *PyWin_SetAPIErrorOrReturnNone(char *fnName, long err = ERROR_SUCCESS);
Expand Down
4 changes: 2 additions & 2 deletions win32/src/PyWinTypesmodule.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ HINSTANCE PyWin_GetErrorMessageModule(DWORD err)
}

/* error helper - GetLastError() is provided, but this is for exceptions */
PyObject *PyWin_SetAPIError(char *fnName, long err /*= 0*/)
PyObject *PyWin_SetAPIError(char *fnName, long err /*= ERROR_SUCCESS*/)
{
DWORD errorCode = err == 0 ? GetLastError() : err;
DWORD errorCode = err == ERROR_SUCCESS ? GetLastError() : err;
DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS;
// try and find the hmodule providing this error.
HMODULE hmodule = PyWin_GetErrorMessageModule(errorCode);
Expand Down

0 comments on commit e325b62

Please sign in to comment.