Conversation
|
This replaces #301? |
src/runtime/runtime.cs
Outdated
| PyImport_GetModuleDict(); | ||
|
|
||
|
|
||
| #if !(PYTHON26 || PYTHON27) |
There was a problem hiding this comment.
Can this be #if PYTHON3 ?
|
Yes, it's an alternative using directly the Python API function. |
| using (new PythonEngine()) | ||
| using (var argv = new PyList(Runtime.Runtime.PySys_GetObject("argv"))) | ||
| { | ||
| Assert.That(argv.Length() != 0); |
There was a problem hiding this comment.
first need to check that it is not null
There was a problem hiding this comment.
Why? If it is null, this will fail with a NullReferenceException, perfectly fine. This PR is supposed to ensure that sys.argv is always initialised.
src/runtime/Python.Runtime.csproj
Outdated
| <Optimize>false</Optimize> | ||
| <DebugType>full</DebugType> | ||
| <PlatformTarget>x64</PlatformTarget> | ||
| <DefineConstants>TRACE;DEBUG;PYTHON3;PYTHON35;UCS2</DefineConstants> |
There was a problem hiding this comment.
this gets overwritten by setup.py or specific needs of the user, so no need to update this
There was a problem hiding this comment.
He probably added that during his development and forgot to remove it.
There was a problem hiding this comment.
Updated #346 to include configuration for PY3 development.
There was a problem hiding this comment.
Yep, exactly that, I'll remove this line.
|
I'm OK with merging this version as long as comments are addressed |
Checks whether an error occurred and in case it has throws a PythonException.
In particular in Py.Import.
|
@filmor rebased your work here |
174e1fa to
3785c40
Compare
Codecov Report@@ Coverage Diff @@
## master #347 +/- ##
==========================================
- Coverage 61.45% 61.37% -0.08%
==========================================
Files 61 61
Lines 5336 5369 +33
Branches 900 896 -4
==========================================
+ Hits 3279 3295 +16
- Misses 1819 1853 +34
+ Partials 238 221 -17
Continue to review full report at Codecov.
|
|
@filmor the coverage on pythonengine.cs reduced |
|
It's probably the refactoring he did. The coverage needs some fine tuning, its definetly not as robust as python's coverage engine. |
| int size = name + ascii.Length + 1; | ||
| IntPtr ptr = Marshal.AllocHGlobal(size); | ||
| for (int i = 0; i <= m_free; i += IntPtr.Size) | ||
| for (int i = 0; i < m_free; i += IntPtr.Size) |
| /// This class provides the public interface of the Python runtime. | ||
| /// </summary> | ||
| public class PythonEngine | ||
| public class PythonEngine : IDisposable |
There was a problem hiding this comment.
why is this now IDisposable?
There was a problem hiding this comment.
Because that's easier to use correctly than Initialize and Shutdown.
| { | ||
| throw new PythonException(); | ||
| } | ||
| Py.Throw(); |
There was a problem hiding this comment.
why not also check for IntPtr.Zero?
There was a problem hiding this comment.
Because this function either returns null and sets an exception, or it returns a module.
| { | ||
| Initialize(Enumerable.Empty<string>()); | ||
| } | ||
|
|
There was a problem hiding this comment.
i did not click submit review few weeks ago
What does this implement/fix? Explain your changes.
Implements an overload of
Initializeand aPy.SetArgvfunction that allow the user to issue aPySys_SetArgvExcall. By default, this call is done onInitializewith a list that contains a single empty string (['']), using the arguments supplied to the .NET process if available.Does this close any currently open issues?
#299.
Any other comments?
Based on the
fix-shutdownbranch as otherwise I'm not able to run the unit-tests reliably..