Skip to content

Commit 76d00df

Browse files
committed
Update traceback and win32com error support to native unicode
1 parent fc69a1e commit 76d00df

34 files changed

Lines changed: 270 additions & 351 deletions

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ However contributors are encouraged to add their own entries for their work.
66

77
Note that build 228 was the last version supporting Python 2.
88

9+
Since build 303:
10+
----------------
11+
* Fixed codepage/mojibake issues when non-ascii characters were included in
12+
COM exceptions raised by Python apps. This should be invisible, but might
13+
break any workarounds which were used, such as using specific encodings in
14+
these strings. (#1823, #1833)
15+
916
Since build 302:
1017
----------------
1118
* Tweaks to how DLLs are loaded and our installation found, which should

Pythonwin/win32uimodule.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,13 @@ BOOL DisplayPythonTraceback(PyObject *exc_type, PyObject *exc_val, PyObject *exc
503503
SetWindowText(title);
504504
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
505505
GetDlgItem(IDOK)->SetWindowText(_T("Close"));
506-
char *msg = GetPythonTraceback(m_exc_type, m_exc_value, m_exc_tb);
507-
char *msg_free = msg;
506+
WCHAR *msg = GetPythonTraceback(m_exc_type, m_exc_value, m_exc_tb);
507+
WCHAR *msg_free = msg;
508508
// Translate '\n' to '\r\n' - do it the easy way!
509509
CString useMsg;
510510
for (; *msg; msg++)
511-
if (*msg == '\n')
512-
useMsg += "\r\n";
511+
if (*msg == L'\n')
512+
useMsg += L"\r\n";
513513
else
514514
useMsg += *msg;
515515
free(msg_free);
@@ -659,7 +659,7 @@ void DefaultExceptionHandler(int action, const TCHAR *context, const TCHAR *extr
659659
}
660660
else
661661
PyErr_Restore(type, value, traceback);
662-
fprintf(stderr, "%s\n", context);
662+
fwprintf(stderr, L"%s\n", context);
663663
// Now print it.
664664
PyErr_Print();
665665
}

com/win32com/makegw/makegwenum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _write_enumgw_cpp(f, interface):
267267
error:
268268
PyErr_Clear(); // just in case
269269
Py_DECREF(result);
270-
return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnum%(enumtype)s, "Next() did not return a sequence of objects");
270+
return PyCom_HandleIEnumNoSequence(IID_IEnum%(enumtype)s);
271271
}
272272
273273
STDMETHODIMP PyGEnum%(enumtype)s::Skip(
@@ -324,7 +324,7 @@ def _write_enumgw_cpp(f, interface):
324324
/* done with the result; this DECREF is also for <punk> */
325325
Py_DECREF(result);
326326
327-
return PyCom_SetCOMErrorFromSimple(hr, IID_IEnum%(enumtype)s, "Python could not convert the result from Next() into the required COM interface");
327+
return PyCom_CheckIEnumNextResult(hr, IID_IEnum%(enumtype)s);
328328
}
329329
"""
330330
% locals()

0 commit comments

Comments
 (0)