| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 46d56af commit c6cc3da
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,5 +57,20 @@ public void TestExec() | |||
| 57 | 57 | object c = locals.GetItem("c").AsManagedObject(typeof(int)); | |
| 58 | 58 | Assert.AreEqual(111, c); | |
| 59 | 59 | } | |
| 60 | + | ||
| 61 | + [Test] | ||
| 62 | + public void TestExec2() | ||
| 63 | + { | ||
| 64 | + string code = @" | ||
| 65 | + class Test1(): | ||
| 66 | + pass | ||
| 67 | + | ||
| 68 | + class Test2(): | ||
| 69 | + def __init__(self): | ||
| 70 | + Test1() | ||
| 71 | + | ||
| 72 | + Test2()"; | ||
| 73 | + PythonEngine.Exec(code); | ||
| 74 | + } | ||
| 60 | 75 | } | |
| 61 | 76 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -496,12 +496,10 @@ internal static PyObject RunString(string code, IntPtr? globals, IntPtr? locals, | |||
| 496 | 496 | borrowedGlobals = false; | |
| 497 | 497 | } | |
| 498 | 498 | } | |
| 499 | - | ||
| 500 | - var borrowedLocals = true; | ||
| 499 | + | ||
| 501 | 500 | if (locals == null) | |
| 502 | 501 | { | |
| 503 | - locals = Runtime.PyDict_New(); | ||
| 504 | - borrowedLocals = false; | ||
| 502 | + locals = globals; | ||
| 505 | 503 | } | |
| 506 | 504 | ||
| 507 | 505 | try | |
@@ -516,10 +514,6 @@ internal static PyObject RunString(string code, IntPtr? globals, IntPtr? locals, | |||
| 516 | 514 | } | |
| 517 | 515 | finally | |
| 518 | 516 | { | |
| 519 | - if (!borrowedLocals) | ||
| 520 | - { | ||
| 521 | - Runtime.XDecref(locals.Value); | ||
| 522 | - } | ||
| 523 | 517 | if (!borrowedGlobals) | |
| 524 | 518 | { | |
| 525 | 519 | Runtime.XDecref(globals.Value); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments