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

Fix the issue of sys.argv being cleared on import clr.#405

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 1 commit intopythonnet:masterfromfilmor:fix-sysargv-import
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletionssrc/runtime/pythonengine.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,7 +122,12 @@ public static int RunSimpleString(string code)

public static void Initialize()
{
Initialize(Enumerable.Empty<string>());
Initialize(setSysArgv: true);
}

public static void Initialize(bool setSysArgv = true)
{
Initialize(Enumerable.Empty<string>(), setSysArgv: setSysArgv);
}

/// <summary>
Expand All@@ -134,7 +139,7 @@ public static void Initialize()
/// first call. It is *not* necessary to hold the Python global
/// interpreter lock (GIL) to call this method.
/// </remarks>
public static void Initialize(IEnumerable<string> args)
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
{
if (!initialized)
{
Expand All@@ -148,7 +153,8 @@ public static void Initialize(IEnumerable<string> args)
initialized = true;
Exceptions.Clear();

Py.SetArgv(args);
if (setSysArgv)
Py.SetArgv(args);

// register the atexit callback (this doesn't use Py_AtExit as the C atexit
// callbacks are called after python is fully finalized but the python ones
Expand DownExpand Up@@ -213,7 +219,7 @@ public static void InitExt()
{
try
{
Initialize();
Initialize(setSysArgv: false);

// Trickery - when the import hook is installed into an already
// running Python, the standard import machinery is still in
Expand Down
3 changes: 0 additions & 3 deletionssrc/tests/test_sysargv.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,12 +4,9 @@

import sys

import pytest

from ._compat import check_output


@pytest.mark.xfail(reason="argv being reset on import clr. See gh#404")
def test_sys_argv_state(filepath):
"""Test sys.argv state doesn't change after clr import.
To better control the arguments being passed, test on a fresh python
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp