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

Skip to content

Commit 3225465

Browse files
committed
Deprecate public RunString
Had to remove defaults to disambiguate call on `internal RunString`. Can re-add after removing `public RunString` Closes pythonnet#401
1 parent 365cd6e commit 3225465

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
3838
- Unfroze Mono version on Travis (#345)
3939
- Changed `conda.recipe` build to only pull-requests (#345)
4040

41+
### Deprecated
42+
43+
- Deprecated `RunString` (#401)
44+
4145
### Fixed
4246

4347
- Fixed crash during Initialization (#262)(#343)
@@ -52,7 +56,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
5256
- Fixed `Py_Main` & `PySys_SetArgvEx` `no mem error` on `UCS4/PY3` (#399)
5357
- Fixed `Python.Runtime.dll.config` on macOS (#120)
5458
- Fixed crash on `PythonEngine.Version` (#413)
55-
- Fixed `PythonEngine.PythonPath` issues (#414)
59+
- Fixed `PythonEngine.PythonPath` issues (#179)(#414)(#415)
5660

5761
### Removed
5862

src/runtime/pythonengine.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,24 @@ public static void Exec(string code, IntPtr? globals = null, IntPtr? locals = nu
469469

470470

471471
/// <summary>
472-
/// RunString Method
472+
/// RunString Method. Function has been deprecated and will be removed.
473+
/// Use Exec/Eval/RunSimpleString instead.
474+
/// </summary>
475+
[Obsolete("RunString is deprecated and will be removed. Use Exec/Eval/RunSimpleString instead.")]
476+
public static PyObject RunString(string code, IntPtr? globals = null, IntPtr? locals = null)
477+
{
478+
return RunString(code, globals, locals, RunFlagType.File);
479+
}
480+
481+
/// <summary>
482+
/// Internal RunString Method.
473483
/// </summary>
474484
/// <remarks>
475485
/// Run a string containing Python code. Returns the result of
476486
/// executing the code string as a PyObject instance, or null if
477487
/// an exception was raised.
478488
/// </remarks>
479-
public static PyObject RunString(
480-
string code, IntPtr? globals = null, IntPtr? locals = null, RunFlagType _flag = RunFlagType.File
481-
)
489+
internal static PyObject RunString(string code, IntPtr? globals, IntPtr? locals, RunFlagType flag)
482490
{
483491
var borrowedGlobals = true;
484492
if (globals == null)
@@ -502,12 +510,10 @@ public static PyObject RunString(
502510
borrowedLocals = false;
503511
}
504512

505-
var flag = (IntPtr)_flag;
506-
507513
try
508514
{
509515
IntPtr result = Runtime.PyRun_String(
510-
code, flag, globals.Value, locals.Value
516+
code, (IntPtr)flag, globals.Value, locals.Value
511517
);
512518

513519
Runtime.CheckExceptionOccurred();

0 commit comments

Comments
 (0)