Skip to content

Ensure that sys.argv is set #301

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2017
Merged

Ensure that sys.argv is set #301

merged 2 commits into from
Feb 8, 2017

Conversation

den-run-ai
Copy link
Contributor

@tonyroberts
Copy link
Contributor

Why not use PySys_SetArgvEx?

@den-run-ai
Copy link
Contributor Author

@tonyroberts because it is very simple one-liner and we already have 3 places in pythonengine.cs, where RunString() is used similarly and it is also tested. What is the benefit of using PySys_SetArgvEx, which is not exposed in pythonnet yet?

Anyway we should probably remove PySys_SetArgv in the pythonnet API, because it has security vulnerability due to default updatepath set to 1:

https://docs.python.org/2/c-api/init.html#c.PySys_SetArgvEx

@filmor filmor changed the title Update runtime.cs Ensure that sys.argv is set Dec 7, 2016
@filmor
Copy link
Member

filmor commented Dec 7, 2016

Since this is the initial setup we wouldn't pass in updatepath = 1. The function pointers aren't available to users anyhow as all of them are marked as internal.

I'm with @tonyroberts, we should use Python's API directly whenever available. I also don't really agree with the values you're setting here, doesn't it make more sense to

  1. Set them by default to the argv of the .NET application if available
  2. Allow the user to override this by calling Py.SetArgv(someArray)?

@filmor filmor mentioned this pull request Jan 9, 2017
9 tasks
@den-run-ai
Copy link
Contributor Author

den-run-ai commented Jan 22, 2017

While writing the tests I realized that with this change now even "import clr" resets sys.argv. Hence need to check in advance if sys.argv is already set. If not, then set it to list with empty string.

@filmor how would I know .NET applications args from public static int Main(string[] args) call without actually being in the scope of this main method? I think this is not available to Python.Runtime.DLL.

@vmuriart
Copy link
Contributor

@denfromufa I got stuck on the same predicament about finding the args. I think that part should be skipped for now.

@filmor
Copy link
Member

filmor commented Jan 22, 2017

@denfromufa System.Environment.GetCommandLineArgs() should do it. But I got stuck with the "reinitialise" issue before, so I didn't finish my alternative PR. Are you suggesting we should skip this for the 2.2.0 release? Let's discuss this over there then.

Copy link
Contributor

@vmuriart vmuriart left a comment

Choose a reason for hiding this comment

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

A couple changes on some "extra" files changes.

Otherwise looks good to me. I can push the changes I mentioned above if you ok w that.

.gitignore Outdated
@@ -54,3 +54,4 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
/NUnit-3.5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

**/packages/* should cover this already if you are using the project default version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry this slipped through - I was not intending to check-in Nunit changes.

GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need another solution. Add the pyproject to the pythonnet.sln instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, I'm not sure if everyone uses PTVS by default :) How does it look with pyproj in solution, but PTVS not installed? if that's not borken, then I agree that having pyproj in solution is fine!

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't find any references to it and I forgot I have ptvs instaled too.

Copy link
Contributor

@vmuriart vmuriart Jan 23, 2017

Choose a reason for hiding this comment

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

@denfromufa just tried combining to 1 solution and running the solution on a machine without ptvs. It loaded the solution no problem, it asked me if i wanted to installed ptvs to load up the project. I declined, and it just grays out the project and everything else worked fine. It didn't ask me again if i reloaded the solution.

The project file needs to be cleaned up though to sanitize the configurations, otherwise it pollutes the current solution. I'm ok with deleting the solution and leaving the pyproj without adding it to the current solution on this pr.

No issues building in travis, still waiting on appveyor...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good finding, perhaps we should get some help from PTVS MS team for promoting their work :)

@den-run-ai
Copy link
Contributor Author

@filmor @vmuriart I'm almost done with this pull request, let me add user facing API and check for System.Environment.GetCommandLineArgs().

vmuriart
vmuriart previously approved these changes Jan 23, 2017
@den-run-ai
Copy link
Contributor Author

@vmuriart @filmor I added more changes to grab CLR arguments if available (may need some tests). please review. I do not intend to add user facing API at this moment.

@vmuriart
Copy link
Contributor

The more I think about it, the less I like the reading the .net env args. The behavior might not be what the user expects, and we may be forcing it onto them. I'm ok with the pr with the exception of the very last commit, my gut feeling is that its going to cause headaches.

@vmuriart vmuriart dismissed their stale review January 23, 2017 06:21

re-reviewing

Copy link
Contributor

@vmuriart vmuriart left a comment

Choose a reason for hiding this comment

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

I'm ok approving without the last commit. We can add it post 2.2.0 release, but I don't want to include it with the release.

This was referenced Jan 25, 2017
@filmor
Copy link
Member

filmor commented Feb 1, 2017

Obsoleted by #347.

@filmor filmor closed this Feb 1, 2017
@filmor filmor deleted the setsysargv branch February 1, 2017 09:19
@vmuriart
Copy link
Contributor

vmuriart commented Feb 1, 2017

@filmor @denfromufa did we want to keep some of the tests?

@den-run-ai
Copy link
Contributor Author

@vmuriart does the coverage increase if you add these tests? :)

@filmor
Copy link
Member

filmor commented Feb 1, 2017

Ooh, sorry missed those. Yeah, we should probably add them.

@den-run-ai
Copy link
Contributor Author

@filmor can you please reopen this one to add the remaining tests?

I cannot do that because the branch is deleted.

@vmuriart vmuriart restored the setsysargv branch February 7, 2017 02:52
@vmuriart
Copy link
Contributor

vmuriart commented Feb 7, 2017

@denfromufa I just restored your branch. (or did you mean @filmor's branch from his work)

@den-run-ai
Copy link
Contributor Author

OK, let me add the remaining tests, if any. Thanks @vmuriart

@den-run-ai den-run-ai reopened this Feb 7, 2017
@vmuriart
Copy link
Contributor

vmuriart commented Feb 7, 2017

might be easiest to create a new branch/pr and copy the tests from this one over to avoid dealing w the merge conflicts and reverting/cleaning other changes.

@codecov
Copy link

codecov bot commented Feb 8, 2017

Codecov Report

Merging #301 into master will not impact coverage.

@@           Coverage Diff           @@
##           master     #301   +/-   ##
=======================================
  Coverage   62.72%   62.72%           
=======================================
  Files          61       61           
  Lines        5253     5253           
  Branches      876      876           
=======================================
  Hits         3295     3295           
  Misses       1740     1740           
  Partials      218      218

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8afd512...2eef75f. Read the comment docs.

@den-run-ai den-run-ai dismissed vmuriart’s stale review February 8, 2017 05:18

please review the added unit tests, CI is passing

@den-run-ai den-run-ai requested a review from vmuriart February 8, 2017 05:19
@den-run-ai
Copy link
Contributor Author

@filmor @tonyroberts @vmuriart please review the added unit tests, CI is passing

Assert.IsNotNull(module, ">>> import PyImportTest.test.one # FAILED");
PyObject module1 = PythonEngine.ImportModule("PyImportTest.test.one");
Assert.IsNotNull(module1, ">>> import PyImportTest.test.one # FAILED");
PyObject module2 = PythonEngine.ImportModule("PyImportTest.sysargv");
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be its own test, not part of the previous one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, let me move it

"""Test sys.argv state."""
argv = list(sys.argv) # need to make a copy of list
import clr
self.assertTrue(argv == sys.argv)
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't make sense. Did importing clr previous cause sys.argv to change? Other tests import clr before this test, that may change being too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is to ensure that importing clr does not mess sys.argv, when it is not empty. what do you mean by "that may change being too."?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no idea what I was trying to write... I meant to say, that since other tests are doing import clr before this test, the library is already loaded into memory and won't be reimported and the import clr statement may do nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, that is a great point! then this needs to be the first test in the test runner before clr is loaded.

Copy link
Contributor

Choose a reason for hiding this comment

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

clr is loaded before all tests being. its the 5th line on run_tests.py i think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was missed, still importing clr before setargv test

@vmuriart vmuriart merged commit 79eeb61 into master Feb 8, 2017
@vmuriart vmuriart deleted the setsysargv branch February 8, 2017 17:44
@vmuriart
Copy link
Contributor

vmuriart commented Feb 8, 2017

Just applied the changes needed and squash merged since the history was a bit messy.


def test_sys_argv_state(self):
"""Test sys.argv state doesn't change after clr import."""
argv = sys.argv
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be argv = list(sys.argv) - need to make a copy

AlexCatarino added a commit to QuantConnect/pythonnet that referenced this pull request Jun 1, 2017
* Sanitize how to run tests

* Remove unsupported entry points
* Adds reference to Python.Test by default for all tests
* Remove redundant add_reference
* Avoid some implicit AddReferences that were being done

Not all tests added reference to Python.Test consistently. Solve this by making `run_test` the only supported method.

* Remove dependency on six

Remove six.u(...), six.b(...)

Not needed since dropped older python versions

* Clean-up imports

- Fix py2/py3 range/zip behavior
  - Ensure same functions being used
- Fix Exception/System.Exception name clashes

* Fix nameclash object

* Refactor utility functions

* Rename tests

* Refactor assertRaises

test_exceptions: Add exc_info test & fix Exception nameclash

* Format for pep8 and linters

Fix max min nameclash

* Fix tests comparison to None, True, False, isinstance

- Replace type(()) with tuple to clarify intent

* Rename test fixtures

Can mess with test discovery

* Remove unused `using` from testing and format

* Use unittest.skip(...)

* Cleanup testing format

* XML Docs on test fixtures

* Update CHANGELOG

* Implement Py.SetArgv.

* Add a `Py.Throw` function.

Checks whether an error occurred and in case it has throws a
PythonException.

* Add overload for Initialize to pass specific args.

* Allow the engine to be initialized as a Disposable.

* Use Py.Throw in a few more places.

In particular in Py.Import.

* Add PY3.7 to travis with allow_failure

* Format & Whitespace

*.cs linelength 120
Allman

* Update CHANGELOG

* Change applicable comments to xml-docs

* Update API website on docs & fix section headers

Runtime.cs section headers got changed to docs.

* Alias root.pyHandle to py_clr_module

* Syntax cleanup

* Simple classes cleanup (pythonnet#348)

* Standarize properties used across projects

Console had it owns set of properties going on

* Add pyproj from @denfromufa

Corrected the configs, won't interfere with users without PTVS

* Consolidate output paths

http://stackoverflow.com/questions/30191387/what-are-the-consequences-of-setting-same-output-path-for-all-configurations

* Fix clrmodule config mismapping

* Add PY3 project/sln configs

* Update test PyImport path

Changed when consolidate output paths

* Update runtime.csproj

* Documentation clean-up

* Downgrade to nunit2

* Syntax cleanup

* Update CHANGELOG

* Clarify pynetinit.c, runtime build directives

pynetinit.c:
Clarifiy its intent is for PY3

runtime.cs
Remove unnecessary check for System.Text
Simplifies import section

* Whitespace converter.cs

* Propercase AssemblyInfo

* Refactor nativemethods

* Rename `is32bit` to `Is32Bit` for naming consistency

* Replace UCS2/UCS4 build directive with Runtime.UCS

* Add IsPython2 and IsPython3

* Cleanup runtime config

* Remove extra properties/Organize properties

* Refactor property conditions

* Order Runtime.csproj configuration

To make it easier to verify everything is setup correctly
Simplified the Mono.Unix include condition

* Add pylong lost unit test

Wasn't being referenced in the project

* Replace #if DEBUG with conditional attribute

* Fix and disable StrongNameSigning

It works better if they key is in the right folder and its being referenced when signing.
It breaks InternalsVisibleTo though, disabling till have time to look into it. (not that it was actually enabled)

* Fix debug statement & rename debugprint

* Document nPython/Console usage

Closes pythonnet#358

* Quiet Test Fixture build warnings about unused events.

They will be used (or attempted to be used) from Python.

* Mono dependency removed from Linux build.

* Remove mono dependency from PY2 as well.

* Replace bufLength with size

* Remove arch .il files

* Update CHANGELOG

* Remove Mono.Unix reference from project

Remove duplicate property in Python.Test

* Clean-up deprWarning

* Clean-up attribute names and paranthesis

* Use explicit accessors

* Clean-up code-style

Remove redundant parenthesis, enforce brackets, use keywork types.

* Remove obsoleted & Unenforced PermissionSet

See: http://stackoverflow.com/questions/11625447/securityaction-requestminimum-is-obsolete-in-net-4-0

* Add expire to license shield

Github Cache issue

github/markup#224

* Remove usage of #region

It hides away the code in Visual Studio

* Turn on NUNIT exit code

* Fix GC on PyObject during Finalizing

Similar to how `PythonDerivedType` finalizes.

Closes pythonnet#364
Possibly related to pythonnet#245

* Update CHANGELOG

* Add sys.args tests (pythonnet#301)

* Use NUnit from Nuget to ensure right version.

* Simplify Embedded tests & Add new tests (pythonnet#369)

* Add Tuple tests

* Update AppVeyor comments and show when tests start.

* Rename InitializeTest to pyinitialize

Keep consistent with other test classes.

* Simplify embed_tests

Since the previous bug involving initialize/finalize have been solved,
we can confidently upgrade these test to use simpler format.

Also Remove Assert fail messages
NUnit already says the name of which test failed.

* Add e-mail to remove setup.py warnings

* Update NUnit syntax

Use xUnit2 and nUnit3 friendly syntax

* Use string interpolation

Removed extra newline at beginning from deprecation warning message

* Replace PyString_FromStringAndSize usage to PyString_FromString

* Fix xml-docs build warnings

* Refactor AppVeyor/Travis embedded test_runner

Make it easier to diff and upgrade versions by
breaking into multiple lines and using path completion

Powershell continuation: http://stackoverflow.com/a/2608186/5208670
Powershell options splatting: http://stackoverflow.com/a/24313253/5208670

* Add pytest to CI

pytest on travis initially required `sudo=required` otherwise failed.
Without the sudo flag pytest wasn't being upgraded. Needed to force
upgrade.

pytest-dev/pytest#2240

* Convert unittest to pytest

Needs local imports to work.
Conversion done with unittests2pytests and a couple regex

* Add setup.cfg

Control settings for some add-ons like pytest

* Simpler tox

* Upgrade NUnit to 3.6

* Fix coverage w NUnit3; add OpenCover filter

NUnit3/OpenCover behavior changed.
Filter removes coverage from Embedded test files by
focusing only on types of Python.Runtime.*

* Remove check-manifest

* Add overload tests from pythonnet#131

* Refactor converter.cs & methodbind*.cs (pythonnet#375)

* Cleanup/Comment Python.Runtime.dll.config & travis

We don't need the `*.dll` variant since we don't call for those
in `runtime.cs`

Enable embedded tests on travis

* Add LD_LIBRARY_PATH to travis env

Find dlls for embedded tests on PY3

* Find dll for PY2 travis embedded tests

Copy Python.Runtime.dll.config to embedded tests bin output

* Generalize LD_LIBRARY_PATH

Avoid having to manually update python/travis versions

* Add GetPrecedence reference

* Use builtin miniconda

* Update version (pythonnet#379)

* Update setup.py

* Update clr.py

* StackOverflow/Slack shields (pythonnet#384)

Add StackExchange and Slack shields

Shields got too long for a single line, had to break them up into two lines.
One for build/quality status, the other for social/info.

Add regression number to disabled code.

* Slack integration for Travis and Appveyor (pythonnet#386)

* Add Slack integration for Travis

* Use encrypted string for Travis.

* Add hook for Appveyor.

* Simplify LD_LIBRARY_PATH on Travis

Based from: http://stackoverflow.com/a/24115039/5208670
Moved to own section to separate as a prep-enviroment step

* Rename NUnit vars to generic names

Makes it easier to switch test-runners in the future.
Note the if section is being skipped for NUnit3, but leaving it
in case needed to rollback to NUnit2, or upgrade to XUnit

* Remove python test STDERR redirect

Pytest doesn't need stderr redirect. It behaves

* Clean-up AppVeyor build recipe

Conda automatically updates when doing install. To disable its autoupdate add

    conda config --set auto_update_conda False

* Add requirements.txt and pytest options

Pytest options provide summary for skipped/xfailed tests
and adds color on appveyor

* Quiet sdist output & update comments on AppVeyor

* Add pytest header info & remove unused fixtures

Fixtures came from a different project and I forgot to delete them.
Add custom header to gather environment info with test results.

Remove testdir from pythonpath. pytest handles this on conftest.py

* Move Conda env to PowerShell recipe script

PY_VER removes the `.` it is used on appveyor_build_recipe.ps1

* Use Codecov report flags

Upgrade to Codecov v2.0.6, didn't get released to PyPi.

* Clean-up CI configs

* Update CHANGELOG

* Pass arbitrary .NET object as value of an attr of PyObject by dyn type(pythonnet#373)

* Add Coverity badge

* Clean-up CHANGELOG

* Standardize Python.Test fixture location

Ensures that Python.Test is output to same location on both Linux and Windows
as part of build.

.gitkeep to be ensure folder is part of version control.
Can be removed if any file is added to it.

* Add unittest for Overflow/across AppDomains Exceptions reproduction (pythonnet#393)

First exception shows issue from pythonnet#376

* Re-order Initialize tests

* Add documentation and ref to ReInitialize test

* Split and re-order TestPyTupleIsTupleType test

* Skip PyTuple test with AppDomain issue

This skip removes the issue from all PY3 on Travis/AppVeyor.
PY27 still has issue randomly on both Travis/AppVeyor x86, x64,.

* Clean-up embedded tests

Clean-up embedded tests comments and variable types

Remove TestFixture attribute. Optional since NUnit 2.5

https://nunit.org/index.php?p=testFixture&r=2.6.4

* Fix conda build log stderr->stdout

Recent conda-build update added a new log output to log:info.
Powershell interprets this as an ERROR since its on STDERR.

Prevent accidental auto-update & display INFO before building.
Would have made debugging this psudo-error easier.

* Quiet AppVeyor pip/nuget installs

Reduce verbosity to make relevant information easier to find.
Errors and Warnings are still displayed.

Travis doesn't need this since they have log folding.

* Allow private env:var to force conda build

To trigger conda build, just add/update private env:vars FORCE_CONDA_BUILD
on link below. Easier to debug and no need to edit appveyor yml/ps1

https://ci.appveyor.com/project/USER_NAME/pythonnet/settings/environment

* Update AUTHORS

Add names to a few more contributors

* Rename TearDown to Dispose

Easier for future possible migration to other frameworks

* Relocate Embedded tests fixtures

Each test type should contain its own fixtures.
Reduces weird dependency of each testing framework

* Update LICENSE year & include in recipe

* Update conda-recipe version

Get it from recipe file instead of git-tag.

* Add SharedAssemblyInfo & Update Assembly version

Reset version back down to v2.x from v4.0.0.2

See link below for Semanctic Versioning & .NET
https://codingforsmarties.wordpress.com/2016/01/21/how-to-version-assemblies-destined-for-nuget/

* Add .bumpversion

Configuration based from gh:bumpversion:issues:77#issuecomment-130696156

Usage:
bumpversion major -> increases major and adds `dev` if not present
bumpversion minor -> increases minor and adds `dev` if not present
bumpversion release -> drop the `dev` portion

* Add object overload test

* Add object type to methodbind

* Add more object overload method tests

* Update CHANGELOG

* Enable embedded_tests to Travis w. conditional filters

Add conditional class skip to pytuple for Travis/PY27
Add individual filters to other tests as needed

https://www.amido.com/code/conditional-ignore-nunit-and-the-ability-to-conditionally-ignore-a-test/
http://stackoverflow.com/a/16075029/5208670

* Split blank DefineConstants on `*.csproj`

Visual Studio by default wants to split these.
Any time the csproj is update (new test for example) it splits them.
Splitting them now to not worry about them when reviewing pull_requests.

* Update CHANGELOG

* Fix PythonException GC (pythonnet#400)

Since PythonException doesn't inherit from PyObject, need to reapply
the same fix as from gh:365.

Seen mostly on PY27/Travis on PyTuple tests.
Enable PyTuple tests for PY27/Travis

* Add Eval(...) and Exec(...)

* Keep RunString Public. Fix Assert.AreEqual order

-  Deprecation/Removal should be a separate issue/pr
-  In NUnit/XUnit, expected is the first argument, actual is second. Opposite to how Python does it

* Update CHANGELOG

* Clarify MashalAs on runtime.cs

- Shorten MarshalAsAttribute name
- Put MashalAs'ed argument on own-line
- Flip IF comparison

* Fix runtime Initialize dll nameclash

Looks like dllLocal never changes from IntPtr.Zero

* Update test_sysargv

Previous version didn't test correctly

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

Closes pythonnet#404.

* improve tests.pyproj for intellisense and running tests (pythonnet#395)

* Update tests.pyproj

* Update folder structure

After pytest folders were flatten.
Add code in fixture
Upstream PyImportTest was moved to within Embedded Tests
Add pyproj to editorconfig

* Add case-sensitivity tests

closes #81

* Added branching for ldd command in OSX (pythonnet#406)

* Minor style clean-up runtime/pythonengine

Add missing brackets
Organize using/remove unused
Align arguments

* Fix Py_Main/PySys_SetArgvEx(...) UCS4/PY3 no mem

Based on @dmitriyse work on:
dmitriyse@8a70f09

* Update CHANGELOG, remove extra MarshalAs

* Move PythonBuildDir when not defined

Keep root of solution clean
and out of the way from being imported because its on the `cwd`.

* Update ARCH check

Use sys for x86/x64  check

* Enable TestPyTupleInvalidAppend test

`AppDomain unload` was solved by pythonnet#400.
Closes pythonnet#397.

Possibly also solved pythonnet#245.

* Add tests/refactor existing

* Set language version to 6

Prevent accidental introduction of csharp 7 features.

* Add ICustomMarshaler StrMarshaler

Useful resources
https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.icustommarshaler(v=vs.110).aspx
https://limbioliong.wordpress.com/2013/11/03/understanding-custom-marshaling-part-1/
https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs
http://stackoverflow.com/a/33514037/5208670

* Add ICustomMarshaler StrArrayMarshaler

* Refactor Marshals

* Add ICustomMarshaler Utf8Marshaler

Refactor PyString_FromStringAndSize
Link explains why `MarshalAs(UnmanagedType.LPWStr)` or `CharSet.Unicode` don't work

http://stackoverflow.com/a/25128147/5208670

* Match PyUnicode_AsUnicode signature in UCS2/UCS4

* Refactor GetManagedString

* Remove internal PyUnicode_AS_UNICODE

Its redundant with PyUnicode_AsUnicode now that the signature
is fixed between UCS2/UCS4.

Apply char conversion that work on both UCS2/UCS4

* Refactor Encoding check

This won't change during runtime.

* Remove ExactSpelling

Not needed as Python doesn't define character specific functions

https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.exactspelling(v=vs.110).aspx

* Remove CharSet.Ansi

Its default charset used

https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.charset(v=vs.110).aspx#Anchor_1

* Remove CharSet.Unicode where not needed

CharSet.Unicode is only needed when args are string type.

https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.charset(v=vs.110).aspx

* Remove CallingConvention

* Rename Runtime field `dll` to `PythonDll`

Add remove full qualification

* Remove unneeded unsafe keyword

* Update CHANGELOG

* Add Runtime.CheckExceptionOccurred(...)

Helps refactor exceptions checks

* Replace Py.Throw with Runtime.CheckExceptionOccurred

* Whitespace clean-up Runtime

* Apply consistent name qualification to runtime.cs

* Unify PY3 UCS2/UCS4 unicode methods

CustomMarshal implementation deals w UCS2/4 differences

* Unify PY2 UCS2/UCS4 unicode methods

PyUnicodeEntryPoint is not used for PY3
since it was unified by PEP393.

It could be defined as "PyUnicode_" for PY3 and further unify the code
between PY2/PY3. Not implementing since not all PY3 methods exist in PY2

* Rename internal methods to proper Python API name

- PyUnicode_FromKindAndString to PyUnicode_FromKindAndData
- PyString_AS_STRING to PyString_AsString

* Fix PY27 dll mapping in Linux/macOS

On 5062377 this was fixed for PY3
but left unchanged for PY2.

On linux/macOS the library is aliased `python2.7` while in windows its `python 27`.
Since internally it wasn't mapped to the correct library in Linux/macOS, we had to
remap it again using the dll.config file.

Closes pythonnet#120

* Refactor runtime's dllBase

As long as the API doesn't change on new python minor releases,
all changes needed for new minor versions is isolated to a small
section of code.

* Style clean-up runtime.cs

* Temporary disable Codecov flags

Codecov added a limit of 20 uploads due to current on-going bug
https://docs.codecov.io/blog/week-8-2017

Also fixed flags casing, documentations says has to be lowercase.

* Fix test_multiple_calls_to_initialize

Exception check didn't upgrade syntax from unittests.
Didn't cause issues because test was passing.

* Fix PythonEngine.Version

Add TestPythonEngineProperties.
Ensure PythonEngine properties are working correctly.
Currently only work on 32bit machines.

Closes pythonnet#413

* Add PYTHONPATH/PYTHONHOME default value tests

Current tests crash on 64bit python on windows, and results
get truncated on Linux.

When working, PYTHONHOME should match ENV VAR if set.
AppVeyor has been updated to test against not blank

* Fix get PYTHONHOME/PYTHONPATH marshal

Unlike pythonnet#413, the return type changes between PY2/PY3.
Extended Custom Marshaler to convert IntPtr to Unicode String

* Rename internal StrMarshaler to UcsMarshaler

To clarify that this is meant to be applied on Unicode type IntPtr and not strings like ones.
Made Marshalers internal, don't see a reason to expose it.

* Unset PYTHONHOME in AppVeyor

Its messing with `conda` causing it to fail to start.
Tests in the `pr` pythonnet#415 make this unnecessary.

* Update conda

Update to using conda based on PY36.
Remove reference to deleted `dll.config` file

* Fix PythonEngine PYTHONHOME setter

Keep memory reference & fix PY3 marshal

* Fix set PythonPath, set ProgramName

Note on PythonPath. Its actually mapping to `Py_SetPath` which is
very different from PYTHONPATH env var. There is no test on it
because it should be set to real paths with libraries. Otherwise it
crashes.

2nd Note. `Py_SetPath` doesn't exist on PY27.

* Deprecate public RunString

Had to remove defaults to disambiguate call on `internal RunString`.
Can re-add after removing `public RunString`

Closes pythonnet#401

* Combine Py_DEBUG and PYTHON_WITH_PYDEBUG flags

They both refer to the PyDebug builds but were added at different times.

Closes pythonnet#362

* Remove PYTHON_WITH_WIDE_UNICODE flag

ABIFlags were introduced in PY32, and --with_wide_unicode was removed in PY33.

https://docs.python.org/3/whatsnew/3.3.html#functionality

Closes pythonnet#417

* Refactor PY2/PY3 Marshal in/out String/Unicode

* Refactor runtime.cs

* Fix Py_SetPath not available in PY2

Closes pythonnet#418

* Calculate Runtime fields before Initialization

* Add timing to detect slow tests on pytest

* Rename test classes/files

Make it easier to distinguish if editor tab refers to class or test.

* Add PyTuple Ctor tests

* Define and document Py_IncRef/Py_DecRef

* Add Tests

* Refactor Exception checking on tested classes

* Clean-up Embedded tests

* Add PyList tests

* Add test for pyscript global variable casting

Test for pythonnet#420

* Clean-up README.md example

* Fix typo in README

* Update CHANGELOG.md

* Bump version: 2.3.0.dev1 → 2.3.0 release

* Bump version: 2.3.0.→ 2.4.0.dev0

Can't start at dev1 as bumpversion breaks if we add a minimum start version for dev.

* Build conda recipe on new tags

Ensure that new binaries are generated for releases which are usually not from pull_requests.

Using APPVEYOR_REPO_TAG_NAME because yields shorter syntax
because it's undefined (ie false) when not a tag
and APPVEYOR_REPO_TAG has to be compared to lowercase `true` instead
of `True` like everything else.

Definitions:
APPVEYOR_REPO_TAG_NAME - contains tag name for builds started by tag; otherwise this variable is undefined;
APPVEYOR_REPO_TAG - true if build has started by pushed tag; otherwise false;

https://www.appveyor.com/docs/environment-variables/

* Fix numpy array and README example (pythonnet#427)

* Fix numpy array and README example

Generic Lists were falling through and being classified as `typecode.Object`
To solve this, adding a specific processing branch for `Generic Lists` only
to avoid breaking the changes from 471673a

Closes pythonnet#249

* Update syntax

* Msbuild15 patch (pythonnet#435)

* Update AUTHORS.md

* Update CHANGELOG.md

* Update setup.py

* Update bld.bat

* Create .mention-bot

* WPF DynamicGrid python and XAML layout files (pythonnet#280)

* Support clr.GetClrType() - as in IronPython (pythonnet#433)

* Support clr.GetClrType() - as in IronPython

Implements pythonnet#432

* Tests for clr.GetClrType()

* clr.GetClrType test: ensure bad type raises ArgumentException

* clr.GetClrType - added xml doc comment, updated AUTHORS.md and CHANGELOG.md

* Simplified implementation of clr.GetClrType (taken from IronPython)

* Update .mention-bot

* Update .mention-bot

* Re-add CallingConvention

Closes pythonnet#448

* Allow passing None for nullable args (pythonnet#460)

* Updated CHANGELOG and AUTHORS (pythonnet#462)

* Fixing Travis CI for mono 5.0 (pythonnet#471)

* Fixing setup.py with mono 5.0

* Go back to xbuild

* Trying to figure out the error cause. Apparently xbuild cannot process the Copy section of the pdb file in the projects.

I have commented them out for now, but this is not a real soltion since they are needed in debug versions. Just to se if it fixes the CI.

* Implement named arguments and With semantics in C# embedding side (pythonnet#461)

* Added python "with" construction

* Added some unit tests for new With method

* Renamed With tests for easier grouping

* Support for named arguments to invoke python methods

* Named argument tests cosmetic changed

* Fixed failing test in python 2.7

* Reset line endings in csproj to LF

* Implements Decimal and Datetime support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants