Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add pysetargv#347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vmuriart merged 5 commits intopythonnet:masterfromfilmor:add-pysetargv
Feb 1, 2017
Merged

Add pysetargv#347

vmuriart merged 5 commits intopythonnet:masterfromfilmor:add-pysetargv
Feb 1, 2017

Conversation

filmor
Copy link
Member

@filmorfilmor commentedJan 31, 2017
edited
Loading

What does this implement/fix? Explain your changes.

Implements an overload ofInitialize and aPy.SetArgv function that allow the user to issue aPySys_SetArgvEx call. By default, this call is done onInitialize with 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 thefix-shutdown branch as otherwise I'm not able to run the unit-tests reliably..

@vmuriart
Copy link
Contributor

This replaces#301?

@@ -2027,11 +2027,26 @@ internal unsafe static extern IntPtr
internal unsafe static extern IntPtr
PyImport_GetModuleDict();


#if !(PYTHON26 || PYTHON27)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can this be#if PYTHON3 ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, I'll change it.

@filmor
Copy link
MemberAuthor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

first need to check that it is not null

Copy link
MemberAuthor

@filmorfilmorJan 31, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why? If it isnull, this will fail with aNullReferenceException, perfectly fine. This PR is supposed to ensure thatsys.argv is always initialised.

@@ -92,6 +92,7 @@
<Optimize>false</Optimize>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>TRACE;DEBUG;PYTHON3;PYTHON35;UCS2</DefineConstants>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this gets overwritten by setup.py or specific needs of the user, so no need to update this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

He probably added that during his development and forgot to remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Updated#346 to include configuration for PY3 development.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yep, exactly that, I'll remove this line.

@den-run-ai
Copy link
Contributor

I'm OK with merging this version as long as comments are addressed

@vmuriart
Copy link
Contributor

@codecov-io
Copy link

codecov-io commentedFeb 1, 2017
edited
Loading

Codecov Report

Merging#347 intomaster willincrease coverage by-0.08%.

@@            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
Impacted FilesCoverage Δ
src/runtime/runtime.cs81.32% <ø> (ø)
src/runtime/pythonengine.cs54.16% <36.36%> (-1.18%)
src/runtime/managedtype.cs46.15% <ø> (ø)
src/runtime/delegatemanager.cs87.6% <ø> (ø)
src/runtime/converter.cs75.38% <ø> (ø)
src/runtime/interfaceobject.cs43.75% <ø> (ø)
src/runtime/classderived.cs0% <ø> (ø)
src/runtime/pyobject.cs22.22% <ø> (ø)
src/runtime/exceptions.cs72.8% <ø> (ø)

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatef7f2fc0...3785c40. Read thecomment docs.

@vmuriartvmuriart merged commit3785c40 intopythonnet:masterFeb 1, 2017
vmuriart added a commit that referenced this pull requestFeb 1, 2017
@filmorfilmor mentioned this pull requestFeb 1, 2017
@den-run-ai
Copy link
Contributor

@filmor the coverage on pythonengine.cs reduced

@vmuriart
Copy link
Contributor

It's probably the refactoring he did. The coverage needs some fine tuning, its definetly not as robust as python's coverage engine.

@@ -227,7 +227,7 @@ static ModuleDefOffset()
byte[] ascii = Encoding.ASCII.GetBytes(modulename);
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

where m_free is set?


namespace Python.Runtime
{
/// <summary>
/// This class provides the public interface of the Python runtime.
/// </summary>
public class PythonEngine
public class PythonEngine : IDisposable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

why is this now IDisposable?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Because that's easier to use correctly thanInitialize andShutdown.

{
throw new PythonException();
}
Py.Throw();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

why not also check for IntPtr.Zero?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Because this function either returns null and sets an exception, or it returns a module.

{
Initialize(Enumerable.Empty<string>());
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

don't we need to check if sys.argv is non-empty in the case of extending withimport clr?@filmor@vmuriart anyway let's see if this passes my tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i did not click submit review few weeks ago

@filmorfilmor deleted the add-pysetargv branchMarch 6, 2019 16:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@den-run-aiden-run-aiden-run-ai left review comments

@vmuriartvmuriartvmuriart left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@filmor@vmuriart@den-run-ai@codecov-io

[8]ページ先頭

©2009-2025 Movatter.jp