- Notifications
You must be signed in to change notification settings - Fork752
Closed
Description
Environment
- Pythonnet version: 2.3.0.dev1 (built from master on 23/02/2017)
- Python version: 2.7.13 64bit
- Operating System: Windows 7 64bit
Details
- I tested the pythonnet version from yesterday, 23/02/2017, as we are interested in the bug fix for the method overload issueMethod overload object type #377. I noticed that we are now running into compatibility issues with the package argparse.
The package argparse now only works correctly, if the parsing of the command line arguments is done BEFORE the import statement of pythonnet (import clr).
If I revert my pythonnet version to pythonnet==2.2.2, then the problem disappears.
The following minimal test code illustrates the problem:
file: test.pyimport argparse# import clr # can't put it here, args.arg1 will be Noneparser = argparse.ArgumentParser()parser.add_argument('--arg1', '-a', help='argument 1', dest='arg1')args = parser.parse_args()import clr print('Argument 1 = ')print(args.arg1)
Then I start the script from command line as
python test.py --arg1 "Hello World"
If I run the code with the "import clr" statement after the call to parser.parse_args() then I get the desired output: Argument 1 =hello worldHowever, if I put the "import clr" at the beginning of the file, I get the output:Argument 1 =None
Metadata
Metadata
Assignees
Labels
No labels