Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c122b62

Browse files
committed
revert exceptions.cs and runtime.cs as the changes in them aren't
necessary
1 parent 201137a commit c122b62

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

pythonnet/src/runtime/exceptions.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,12 @@ internal unsafe static void ErrorOccurredCheck(IntPtr pointer) {
222222
///
223223
/// </remarks>
224224
internal static void SetupExceptionHack() {
225-
DebugUtil.Print("SetupExceptionHack");
226225
ns_exc = ClassManager.GetClass(typeof(Exception)).pyHandle;
227226
cache = new Hashtable();
228227

229-
string module_exception =
230-
#if(PYTHON34)
231-
"builtins"
232-
#else
233-
"exceptions"
234-
#endif
235-
;
236-
237228
string code =
238-
"import {0}\n" +
239-
"class Exception({0}.Exception):\n" +
229+
"import exceptions\n" +
230+
"class Exception(exceptions.Exception):\n" +
240231
" _class = None\n" +
241232
" _inner = None\n" +
242233
" \n" +
@@ -248,7 +239,7 @@ internal static void SetupExceptionHack() {
248239
" def __init__(self, *args, **kw):\n" +
249240
" inst = self.__class__._class(*args, **kw)\n" +
250241
" self.__dict__['_inner'] = inst\n" +
251-
" {0}.Exception.__init__(self, *args, **kw)\n" +
242+
" exceptions.Exception.__init__(self, *args, **kw)\n" +
252243
"\n" +
253244
" def __getattr__(self, name, _marker=[]):\n" +
254245
" inner = self.__dict__['_inner']\n" +
@@ -277,8 +268,6 @@ internal static void SetupExceptionHack() {
277268
" name = self.__class__.__name__\n" +
278269
" return '%s(\\'%s\\',)' % (name, msg) \n" +
279270
"\n";
280-
code = string.Format(code, module_exception);
281-
DebugUtil.Print(code);
282271

283272
IntPtr dict = Runtime.PyDict_New();
284273

pythonnet/src/runtime/runtime.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,10 @@ internal static void Initialize() {
199199
// of the Python runtime that do not allow new-style classes to
200200
// be used as exceptions (Python versions 2.4 and lower).
201201

202-
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 )
202+
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
203203
wrap_exceptions = false;
204204
#else
205-
206-
IntPtr m = PyImport_ImportModule(
207-
#if(PYTHON34)
208-
"builtins"
209-
#else
210-
"exceptions"
211-
#endif
212-
);
213-
205+
IntPtr m = PyImport_ImportModule("exceptions");
214206
Exceptions.ErrorCheck(m);
215207
op = Runtime.PyObject_GetAttrString(m, "Exception");
216208
Exceptions.ErrorCheck(op);

0 commit comments

Comments
 (0)