| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,7 +154,6 @@ public static void Initialize(IEnumerable<string> args) | |||
| 154 | 154 | Exceptions.Clear(); | |
| 155 | 155 | ||
| 156 | 156 | Py.SetArgv(args); | |
| 157 | - Py.Throw(); | ||
| 158 | 157 | ||
| 159 | 158 | // register the atexit callback (this doesn't use Py_AtExit as the C atexit | |
| 160 | 159 | // callbacks are called after python is fully finalized but the python ones | |
@@ -382,10 +381,7 @@ public static void EndAllowThreads(IntPtr ts) | |||
| 382 | 381 | public static PyObject ImportModule(string name) | |
| 383 | 382 | { | |
| 384 | 383 | IntPtr op = Runtime.PyImport_ImportModule(name); | |
| 385 | - if (op == IntPtr.Zero) | ||
| 386 | - { | ||
| 387 | - return null; | ||
| 388 | - } | ||
| 384 | + Py.Throw(); | ||
| 389 | 385 | return new PyObject(op); | |
| 390 | 386 | } | |
| 391 | 387 | ||
@@ -401,10 +397,7 @@ public static PyObject ImportModule(string name) | |||
| 401 | 397 | public static PyObject ReloadModule(PyObject module) | |
| 402 | 398 | { | |
| 403 | 399 | IntPtr op = Runtime.PyImport_ReloadModule(module.Handle); | |
| 404 | - if (op == IntPtr.Zero) | ||
| 405 | - { | ||
| 406 | - throw new PythonException(); | ||
| 407 | - } | ||
| 400 | + Py.Throw(); | ||
| 408 | 401 | return new PyObject(op); | |
| 409 | 402 | } | |
| 410 | 403 | ||
@@ -420,15 +413,9 @@ public static PyObject ReloadModule(PyObject module) | |||
| 420 | 413 | public static PyObject ModuleFromString(string name, string code) | |
| 421 | 414 | { | |
| 422 | 415 | IntPtr c = Runtime.Py_CompileString(code, "none", (IntPtr)257); | |
| 423 | - if (c == IntPtr.Zero) | ||
| 424 | - { | ||
| 425 | - throw new PythonException(); | ||
| 426 | - } | ||
| 416 | + Py.Throw(); | ||
| 427 | 417 | IntPtr m = Runtime.PyImport_ExecCodeModule(name, c); | |
| 428 | - if (m == IntPtr.Zero) | ||
| 429 | - { | ||
| 430 | - throw new PythonException(); | ||
| 431 | - } | ||
| 418 | + Py.Throw(); | ||
| 432 | 419 | return new PyObject(m); | |
| 433 | 420 | } | |
| 434 | 421 | ||
@@ -476,10 +463,7 @@ public static PyObject RunString( | |||
| 476 | 463 | code, flag, globals.Value, locals.Value | |
| 477 | 464 | ); | |
| 478 | 465 | ||
| 479 | - if (Runtime.PyErr_Occurred() != 0) | ||
| 480 | - { | ||
| 481 | - throw new PythonException(); | ||
| 482 | - } | ||
| 466 | + Py.Throw(); | ||
| 483 | 467 | ||
| 484 | 468 | return new PyObject(result); | |
| 485 | 469 | } | |
@@ -583,6 +567,7 @@ public static void SetArgv(IEnumerable<string> argv) | |||
| 583 | 567 | { | |
| 584 | 568 | var arr = argv.ToArray(); | |
| 585 | 569 | Runtime.PySys_SetArgvEx(arr.Length, arr, 0); | |
| 570 | + Py.Throw(); | ||
| 586 | 571 | } | |
| 587 | 572 | } | |
| 588 | 573 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments