8000 Since ClassBase not override tp_init for BaseException, repr(Exceptio… · pythonnet/pythonnet@d108913 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit d108913

Browse files
committed
Since ClassBase not override tp_init for BaseException, repr(ExceptionObject) will not care 'u' on Python2.
1 parent 2940973 commit d108913

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/runtime/runtime.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ internal static void Initialize(bool initSigs = false, bool softShutdown = false
227227

228228
SetPyMember(ref PySuper_Type, PyObject_GetAttrString(builtins, "super"));
229229

230-
op = PyObject_GetAttrString(builtins, "KeyError");
231-
SetPyMember(ref PyExc_KeyError, op);
232-
233230
XDecref(builtins);
234231
}
235232

@@ -345,6 +342,7 @@ private static void InitializePlatformData()
345342

346343
fn = PyObject_GetAttrString(platformModule, "system");
347344
op = PyObject_Call(fn, emptyTuple, IntPtr.Zero);
345+
PythonException.ThrowIfIsNull(op);
348346
OperatingSystemName = GetManagedString(op);
349347
XDecref(op);
350348
XDecref(fn);
@@ -470,7 +468,7 @@ private static void PyDictTryDelItem(IntPtr dict, string key)
470468
{
471469
return;
472470
}
473-
if (!PythonException.Matches(PyExc_KeyError))
471+
if (!PythonException.Matches(Exceptions.KeyError))
474472
{
475473
throw new PythonException();
476474
}
@@ -541,8 +539,6 @@ private static void MoveClrInstancesOnwershipToPython()
541539
internal static IntPtr PyNone;
542540
internal static IntPtr Error;
543541

544-
internal static IntPtr PyExc_KeyError;
545-
546542
/// <summary>
547543
/// Check if any Python Exceptions occurred.
548544
/// If any exist throw new PythonException.

src/tests/test_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_python_compat_of_managed_exceptions():
286286
strexp = "OverflowException('Simple message"
287287
assert repr(e)[:len(strexp)] == strexp
288288
elif PY2:
289-
assert repr(e) == "OverflowException(u'Simple message',)"
289+
assert repr(e) == "OverflowException('Simple message',)"
290290

291291

292292
def test_exception_is_instance_of_system_object():

0 commit comments

Comments
 (0)
0