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 OverflowException on 64bit due to bad cast#376

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

Closed
vmuriart wants to merge1 commit intopythonnet:masterfromvmuriart:fix_IntPtr_cast

Conversation

@vmuriart
Copy link
Contributor

What does this implement/fix? Explain your changes.

Fix OverflowException on 64bit due to bad cast

Error message wasOverflowException occurred. Arithmetic operation resulted in an overflow.
Link below explains in more detail the issue. This fixes the issue in both 32/64bit.

https://www.codeproject.com/Answers/899343/How-to-fix-OverflowException-occurred-Arithmetic-o#answer2

Does this close any currently open issues?

Issue found while working on#373.

Copy link
Contributor

@den-run-aiden-run-ai left a comment

Choose a reason for hiding this comment

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

Shouldn't this be Int64 only if 64-bit process, otherwise Int32?

@den-run-ai
Copy link
Contributor

@vmuriart do you now see my review?

#376 (review)

@vmuriart
Copy link
ContributorAuthor

@denfromufa Yup I see it. The casting will do the right thing on both 32 and 64bit systems due to someclr magic (can't find a reference for this).

The issue would be that as part of thismagic on 32bit systems,clr needsto do 2 transactions to update the value. This would be an issue if theflags were a shared variable, but since they aren't it should be safe to use.

@codecov
Copy link

codecovbot commentedFeb 14, 2017
edited
Loading

Codecov Report

Merging#376 intomaster willdecrease coverage by-1.95%.
The diff coverage isn/a.

@@            Coverage Diff            @@##           master    #376      +/-   ##=========================================- Coverage   63.44%   61.5%   -1.95%=========================================  Files          61       1      -60       Lines        5269     200    -5069       Branches      860       0     -860     =========================================- Hits         3343     123    -3220+ Misses       1710      77    -1633+ Partials      216       0     -216
FlagCoverage Δ
#Embedded_Tests?
#Python_Tests?
#Setup_Linux?
#Setup_Windows61.5% <ø> (-9%)
Impacted FilesCoverage Δ
setup.py61.5% <0%> (-26.5%)
src/runtime/fieldobject.cs
src/runtime/codegenerator.cs
src/runtime/delegatemanager.cs
src/runtime/classbase.cs
src/runtime/classobject.cs
src/runtime/interop.cs
src/runtime/CustomMarshaler.cs
src/runtime/interop34.cs
src/runtime/exceptions.cs
... and47 more

Continue to review full report at Codecov.

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

@den-run-ai
Copy link
Contributor

@vmuriart actually it is quite safe to cast intptr to int64 on both architectures. I don't think any clr magic is necessary.

http://stackoverflow.com/a/18173246/2230844

https://msdn.microsoft.com/en-us/library/x65fb868(v=vs.110).aspx

vmuriart reacted with thumbs up emoji

@filmor
Copy link
Member

filmor commentedFeb 15, 2017
edited
Loading

Shouldn't those beReadInt32 calls anyhow? I just checkedtp_flags which is declared as a Clong so it's actually a 32bit integer.

@vmuriart
Copy link
ContributorAuthor

The problem is that the pointers themselves are 64bit integers which is what caused the issue.

TL;DR: You're casting 64-bits IntPtr to a Int32... Which causes "overflow"
https://www.codeproject.com/Answers/899343/How-to-fix-OverflowException-occurred-Arithmetic-o#answer2

@den-run-ai
Copy link
Contributor

den-run-ai commentedFeb 15, 2017 via email

On Wed, Feb 15, 2017, 8:25 AM Victor Uriarte ***@***.***> wrote: The problem is that the pointers themselves are 64bit integers which is what caused the issue. TL;DR: You're casting 64-bits IntPtr to a Int32... Which causes "overflow"https://www.codeproject.com/Answers/899343/How-to-fix-OverflowException-occurred-Arithmetic-o#answer2 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#376 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgZ5Wthwejo6LDDja9CjmhUC1nkTpc9ks5rcwrygaJpZM4MAtkA> .

@vmuriart
Copy link
ContributorAuthor

@denfromufa I made the same mistake earlier as you did.@filmor saidc long which is indeed32bit vsc# long which is 64bit.

@filmor
Copy link
Member

@vmuriartIntPtr issizeof(int*) which is 32bit on x86 and 64bit on x86_64.
@denfromufa That's why I corrected to "Clong", in C on most platforms,long is 32bit, even ifint* is 64bit.

What I'm saying is we currently readtp_flags, which is (at least for the main x86 platforms) a 32bit integer as if it was a pointer, which strikes me as quite a bad idea.

vmuriart reacted with thumbs up emoji

@vmuriart
Copy link
ContributorAuthor

@filmor thanks for the clarification 👍. If i understood correctly, your concern is not with thepull_request but rather with the current implementation oftp_flags being a32bit integer correct?

@filmor
Copy link
Member

No, my concern is with this pull request. If we change something to these struct accesses we should do it right. And the right way is not to read it as pointer-sized and then blowing it up to 64bit. The right way is to find the correct declarations (which will probably always be 32bit integers) and use the respectiveMarshal function on this one.

@den-run-ai
Copy link
Contributor

den-run-ai commentedFeb 15, 2017 via email

@filmor I see now, in my email it still had long, not "c long" :)"C long" is 32-bit on Windows and 64-bit on *Nix OSes. But this isimplementation details and not guaranteed.So ReadIntPtr should take care of architecture differences.
On Wed, Feb 15, 2017, 9:14 AM Victor Uriarte ***@***.***> wrote:@filmor <https://github.com/filmor> thanks for the clarification 👍. If i understood correctly, your concern is not with the pull_request but rather with the current implementation of tp_flags being a 32bit integer correct? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#376 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgZ5dpf879Da4QyQEtTlyGcZbDIVAwNks5rcxZRgaJpZM4MAtkA> .

@filmor
Copy link
Member

It takes care of architecture differences with regard topointers, notlong.

@den-run-ai
Copy link
Contributor

It takes care of architecture differences with regard to pointers, not long.

@filmor you are right, but still "c long" does not have to be 32bit.

@den-run-ai
Copy link
Contributor

@filmor@vmuriart we can use ctypes to determine this!

image

@vmuriart
Copy link
ContributorAuthor

I'll rewrite this after I come back from vacation. The better thing to do is split up the& and do the comparison toIntPtr.Zero to avoid casting at all.

@vmuriart
Copy link
ContributorAuthor

vmuriart commentedFeb 17, 2017
edited
Loading

@yagweb do you still have a way to reproduce this issue we originally saw on#373?
Rather, does the example you provided also create this Overflow issue, or is it just the appdomain issue?

@yagweb
Copy link
Contributor

yagweb commentedFeb 18, 2017
edited
Loading

@vmuriart The unit test function I provided in#373 can reproduce this OverflowException you talk about. After applying you previous fixup with replacing int to Int64, It will raise the appdomain exception two statements after.
To answer you question in#373, I tried and found, using any .NET object in the test function can trigger the exception, not just StringBuilder.

I can create a PR to add the unit test if you need.

@vmuriart
Copy link
ContributorAuthor

vmuriart commentedFeb 18, 2017 via email

Yes please. THat be great
On Fri, Feb 17, 2017 at 16:28 yagweb ***@***.***> wrote:@vmuriart <https://github.com/vmuriart> The example I provided can reproduce this OverflowException you talk about. After applying you previous fixup with replacing int to Int64, It will raise the appdomain issue two statements later. Using any .NET object in the test function can trigger the exception, not just StringBuilder. I can create a PR to add the unit test if you need. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#376 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AMr87PcA4uDekO7OhP03YRTxtrQo2TVWks5rdjtFgaJpZM4MAtkA> .

@den-run-ai
Copy link
Contributor

@vmuriart@filmor do you agree to work ontypeof(tp_flags)==c_long in another pull request? Looks like this localized problem is temporarily resolved withlong. But this code may change as part of the bigger issue. Definitely we cannot use the ctypes approach duringPy_Initialize() and I have not found pinvoke equivalent. We can pass a compilation flag to c# in setup.py to define the size of c_long.

@yagweb
Copy link
Contributor

@vmuriart @denfromufa@filmor A Minimal unit test to reproduce the Overflow Exception and across AppDomains Exception was providedhere.

vmuriart pushed a commit that referenced this pull requestFeb 21, 2017
@vmuriart
Copy link
ContributorAuthor

@denfromufa im ok with continuing the work for this on another PR and applyinglong for now.
For thec_long size, why can't we useruntime.Is32Bit?

Error message was `OverflowException occurred. Arithmetic operation resulted in an overflow.`Link below explains in more detail the issue. This fixes the issue in both 32/64bit.https://www.codeproject.com/Answers/899343/How-to-fix-OverflowException-occurred-Arithmetic-o#answer2Use keyword `long` instead of `System.Int64`Cast is safe. Thanks @denfromufa for the sources.http://stackoverflow.com/a/18173246/2230844https://msdn.microsoft.com/en-us/library/x65fb868(v=vs.110).aspx
@den-run-ai
Copy link
Contributor

den-run-ai commentedFeb 23, 2017 via email

For c_long the size depends on platform implementation details:http://stackoverflow.com/a/2800654/2230844C#/IL cannot be aware of this. Like I suggested we can pass a compilationflag from setup.py to .NET project.
On Wed, Feb 22, 2017, 7:53 PM Victor Uriarte ***@***.***> wrote: @denfromufa <https://github.com/denfromufa> im ok with continuing the work for this on another PR and applying long for now. For the c_long size, why can't we use runtime.Is32Bit? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#376 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgZ5UsYY_SzRDJ03gz05vCiZnPa9cCtks5rfOaGgaJpZM4MAtkA> .

@filmor
Copy link
Member

Meh, we have come so far in having a single build here, I wouldn't want to paddle back just for this one tiny detail. I guess it's easier to just bite the bullet and haveWriteLong andReadLong functions that behave likeR/WIntPtr everywhere and likeR/WInt32 on Windows.

@den-run-ai
Copy link
Contributor

@filmor can explain what you mean by these terms?

R/WIntPtr everywhere and like R/WInt32 on Windows.

@filmor
Copy link
Member

filmor commentedMar 1, 2017
edited
Loading

@denfromufa Shortcuts forReadLong andWriteLong.

@filmorfilmor closed thisMar 1, 2017
@filmorfilmor reopened thisMar 1, 2017
@filmor
Copy link
Member

Sorry, fat-fingered the Close button :/

@filmor
Copy link
Member

I meant a function like this:

long ReadLong(IntPtr ptr, int offset){    if (IsWindows)        return (long)Marshal.ReadInt32(ptr, offset);    return (long)Marshal.ReadIntPtr(ptr, offset);}

Same for write.

AlexCatarino added a commit to QuantConnect/pythonnet that referenced this pull requestJun 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 doneNot all tests added reference to Python.Test consistently. Solve this by making `run_test` the only supported method.* Remove dependency on sixRemove 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 assertRaisestest_exceptions: Add exc_info test & fix Exception nameclash* Format for pep8 and lintersFix max min nameclash* Fix tests comparison to None, True, False, isinstance- Replace type(()) with tuple to clarify intent* Rename test fixturesCan 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 aPythonException.* 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 120Allman* Update CHANGELOG* Change applicable comments to xml-docs* Update API website on docs & fix section headersRuntime.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 projectsConsole had it owns set of properties going on* Add pyproj from @denfromufaCorrected the configs, won't interfere with users without PTVS* Consolidate output pathshttp://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 pathChanged when consolidate output paths* Update runtime.csproj* Documentation clean-up* Downgrade to nunit2* Syntax cleanup* Update CHANGELOG* Clarify pynetinit.c, runtime build directivespynetinit.c:Clarifiy its intent is for PY3runtime.csRemove unnecessary check for System.TextSimplifies 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 configurationTo make it easier to verify everything is setup correctlySimplified the Mono.Unix include condition* Add pylong lost unit testWasn't being referenced in the project* Replace #if DEBUG with conditional attribute* Fix and disable StrongNameSigningIt 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 usageClosespythonnet#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 projectRemove duplicate property in Python.Test* Clean-up deprWarning* Clean-up attribute names and paranthesis* Use explicit accessors* Clean-up code-styleRemove redundant parenthesis, enforce brackets, use keywork types.* Remove obsoleted & Unenforced PermissionSetSee:http://stackoverflow.com/questions/11625447/securityaction-requestminimum-is-obsolete-in-net-4-0* Add expire to license shieldGithub Cache issuegithub/markup#224* Remove usage of #regionIt hides away the code in Visual Studio* Turn on NUNIT exit code* Fix GC on PyObject during FinalizingSimilar to how `PythonDerivedType` finalizes.Closespythonnet#364Possibly related topythonnet#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 pyinitializeKeep consistent with other test classes.* Simplify embed_testsSince the previous bug involving initialize/finalize have been solved,we can confidently upgrade these test to use simpler format.Also Remove Assert fail messagesNUnit already says the name of which test failed.* Add e-mail to remove setup.py warnings* Update NUnit syntaxUse xUnit2 and nUnit3 friendly syntax* Use string interpolationRemoved 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_runnerMake it easier to diff and upgrade versions bybreaking into multiple lines and using path completionPowershell continuation:http://stackoverflow.com/a/2608186/5208670Powershell options splatting:http://stackoverflow.com/a/24313253/5208670* Add pytest to CIpytest on travis initially required `sudo=required` otherwise failed.Without the sudo flag pytest wasn't being upgraded. Needed to forceupgrade.pytest-dev/pytest#2240* Convert unittest to pytestNeeds local imports to work.Conversion done with unittests2pytests and a couple regex* Add setup.cfgControl settings for some add-ons like pytest* Simpler tox* Upgrade NUnit to 3.6* Fix coverage w NUnit3; add OpenCover filterNUnit3/OpenCover behavior changed.Filter removes coverage from Embedded test files byfocusing only on types of Python.Runtime.** Remove check-manifest* Add overload tests frompythonnet#131* Refactor converter.cs & methodbind*.cs (pythonnet#375)* Cleanup/Comment Python.Runtime.dll.config & travisWe don't need the `*.dll` variant since we don't call for thosein `runtime.cs`Enable embedded tests on travis* Add LD_LIBRARY_PATH to travis envFind dlls for embedded tests on PY3* Find dll for PY2 travis embedded testsCopy Python.Runtime.dll.config to embedded tests bin output* Generalize LD_LIBRARY_PATHAvoid 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 shieldsShields 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 TravisBased from:http://stackoverflow.com/a/24115039/5208670Moved to own section to separate as a prep-enviroment step* Rename NUnit vars to generic namesMakes it easier to switch test-runners in the future.Note the if section is being skipped for NUnit3, but leaving itin case needed to rollback to NUnit2, or upgrade to XUnit* Remove python test STDERR redirectPytest doesn't need stderr redirect. It behaves* Clean-up AppVeyor build recipeConda automatically updates when doing install. To disable its autoupdate add    conda config --set auto_update_conda False* Add requirements.txt and pytest optionsPytest options provide summary for skipped/xfailed testsand adds color on appveyor* Quiet sdist output & update comments on AppVeyor* Add pytest header info & remove unused fixturesFixtures 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 scriptPY_VER removes the `.` it is used on appveyor_build_recipe.ps1* Use Codecov report flagsUpgrade 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 locationEnsures that Python.Test is output to same location on both Linux and Windowsas 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 frompythonnet#376* Re-order Initialize tests* Add documentation and ref to ReInitialize test* Split and re-order TestPyTupleIsTupleType test* Skip PyTuple test with AppDomain issueThis skip removes the issue from all PY3 on Travis/AppVeyor.PY27 still has issue randomly on both Travis/AppVeyor x86, x64,.* Clean-up embedded testsClean-up embedded tests comments and variable typesRemove TestFixture attribute. Optional since NUnit 2.5https://nunit.org/index.php?p=testFixture&r=2.6.4* Fix conda build log stderr->stdoutRecent 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 installsReduce 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 buildTo trigger conda build, just add/update private env:vars FORCE_CONDA_BUILDon link below. Easier to debug and no need to edit appveyor yml/ps1https://ci.appveyor.com/project/USER_NAME/pythonnet/settings/environment* Update AUTHORSAdd names to a few more contributors* Rename TearDown to DisposeEasier for future possible migration to other frameworks* Relocate Embedded tests fixturesEach test type should contain its own fixtures.Reduces weird dependency of each testing framework* Update LICENSE year & include in recipe* Update conda-recipe versionGet it from recipe file instead of git-tag.* Add SharedAssemblyInfo & Update Assembly versionReset version back down to v2.x from v4.0.0.2See link below for Semanctic Versioning & .NEThttps://codingforsmarties.wordpress.com/2016/01/21/how-to-version-assemblies-destined-for-nuget/* Add .bumpversionConfiguration based from gh:bumpversion:issues:77#issuecomment-130696156Usage:bumpversion major -> increases major and adds `dev` if not presentbumpversion minor -> increases minor and adds `dev` if not presentbumpversion 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 filtersAdd conditional class skip to pytuple for Travis/PY27Add individual filters to other tests as neededhttps://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 reapplythe 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 nameclashLooks like dllLocal never changes from IntPtr.Zero* Update test_sysargvPrevious version didn't test correctly* Fix the issue of sys.argv being cleared on import clr.Closespythonnet#404.* improve tests.pyproj for intellisense and running tests (pythonnet#395)* Update tests.pyproj* Update folder structureAfter pytest folders were flatten.Add code in fixtureUpstream PyImportTest was moved to within Embedded TestsAdd pyproj to editorconfig* Add case-sensitivity testscloses#81* Added branching for ldd command in OSX (pythonnet#406)* Minor style clean-up runtime/pythonengineAdd missing bracketsOrganize using/remove unusedAlign arguments* Fix Py_Main/PySys_SetArgvEx(...) UCS4/PY3 no memBased on@dmitriyse work on:dmitriyse@8a70f09* Update CHANGELOG, remove extra MarshalAs* Move PythonBuildDir when not definedKeep root of solution cleanand out of the way from being imported because its on the `cwd`.* Update ARCH checkUse sys for x86/x64  check* Enable TestPyTupleInvalidAppend test`AppDomain unload` was solved bypythonnet#400.Closespythonnet#397.Possibly also solvedpythonnet#245.* Add tests/refactor existing* Set language version to 6Prevent accidental introduction of csharp 7 features.* Add ICustomMarshaler StrMarshalerUseful resourceshttps://msdn.microsoft.com/en-us/library/system.runtime.interopservices.icustommarshaler(v=vs.110).aspxhttps://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.cshttp://stackoverflow.com/a/33514037/5208670* Add ICustomMarshaler StrArrayMarshaler* Refactor Marshals* Add ICustomMarshaler Utf8MarshalerRefactor PyString_FromStringAndSizeLink explains why `MarshalAs(UnmanagedType.LPWStr)` or `CharSet.Unicode` don't workhttp://stackoverflow.com/a/25128147/5208670* Match PyUnicode_AsUnicode signature in UCS2/UCS4* Refactor GetManagedString* Remove internal PyUnicode_AS_UNICODEIts redundant with PyUnicode_AsUnicode now that the signatureis fixed between UCS2/UCS4.Apply char conversion that work on both UCS2/UCS4* Refactor Encoding checkThis won't change during runtime.* Remove ExactSpellingNot needed as Python doesn't define character specific functionshttps://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.exactspelling(v=vs.110).aspx* Remove CharSet.AnsiIts default charset usedhttps://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.charset(v=vs.110).aspx#Anchor_1* Remove CharSet.Unicode where not neededCharSet.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 methodsCustomMarshal implementation deals w UCS2/4 differences* Unify PY2 UCS2/UCS4 unicode methodsPyUnicodeEntryPoint is not used for PY3since it was unified by PEP393.It could be defined as "PyUnicode_" for PY3 and further unify the codebetween 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/macOSOn5062377 this was fixed for PY3but 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 toremap it again using the dll.config file.Closespythonnet#120* Refactor runtime's dllBaseAs long as the API doesn't change on new python minor releases,all changes needed for new minor versions is isolated to a smallsection of code.* Style clean-up runtime.cs* Temporary disable Codecov flagsCodecov added a limit of 20 uploads due to current on-going bughttps://docs.codecov.io/blog/week-8-2017Also fixed flags casing, documentations says has to be lowercase.* Fix test_multiple_calls_to_initializeException check didn't upgrade syntax from unittests.Didn't cause issues because test was passing.* Fix PythonEngine.VersionAdd TestPythonEngineProperties.Ensure PythonEngine properties are working correctly.Currently only work on 32bit machines.Closespythonnet#413* Add PYTHONPATH/PYTHONHOME default value testsCurrent tests crash on 64bit python on windows, and resultsget 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 marshalUnlikepythonnet#413, the return type changes between PY2/PY3.Extended Custom Marshaler to convert IntPtr to Unicode String* Rename internal StrMarshaler to UcsMarshalerTo 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 AppVeyorIts messing with `conda` causing it to fail to start.Tests in the `pr`pythonnet#415 make this unnecessary.* Update condaUpdate to using conda based on PY36.Remove reference to deleted `dll.config` file* Fix PythonEngine PYTHONHOME setterKeep memory reference & fix PY3 marshal* Fix set PythonPath, set ProgramNameNote on PythonPath. Its actually mapping to `Py_SetPath` which isvery different from PYTHONPATH env var. There is no test on itbecause it should be set to real paths with libraries. Otherwise itcrashes.2nd Note. `Py_SetPath` doesn't exist on PY27.* Deprecate public RunStringHad to remove defaults to disambiguate call on `internal RunString`.Can re-add after removing `public RunString`Closespythonnet#401* Combine Py_DEBUG and PYTHON_WITH_PYDEBUG flagsThey both refer to the PyDebug builds but were added at different times.Closespythonnet#362* Remove PYTHON_WITH_WIDE_UNICODE flagABIFlags were introduced in PY32, and --with_wide_unicode was removed in PY33.https://docs.python.org/3/whatsnew/3.3.html#functionalityClosespythonnet#417* Refactor PY2/PY3 Marshal in/out String/Unicode* Refactor runtime.cs* Fix Py_SetPath not available in PY2Closespythonnet#418* Calculate Runtime fields before Initialization* Add timing to detect slow tests on pytest* Rename test classes/filesMake 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 castingTest forpythonnet#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.dev0Can't start at dev1 as bumpversion breaks if we add a minimum start version for dev.* Build conda recipe on new tagsEnsure that new binaries are generated for releases which are usually not from pull_requests.Using APPVEYOR_REPO_TAG_NAME because yields shorter syntaxbecause it's undefined (ie false) when not a tagand APPVEYOR_REPO_TAG has to be compared to lowercase `true` insteadof `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 exampleGeneric Lists were falling through and being classified as `typecode.Object`To solve this, adding a specific processing branch for `Generic Lists` onlyto avoid breaking the changes from471673aClosespythonnet#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 IronPythonImplementspythonnet#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 CallingConventionClosespythonnet#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
@filmorfilmor mentioned this pull requestJun 16, 2017
4 tasks
@filmorfilmor closed thisJun 26, 2017
@vmuriartvmuriart deleted the fix_IntPtr_cast branchJuly 4, 2017 23:55
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@filmorfilmorAwaiting requested review from filmor

@tonyrobertstonyrobertsAwaiting requested review from tonyroberts

1 more reviewer

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

Reviewers whose approvals may not affect merge requirements

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

@vmuriart@den-run-ai@filmor@yagweb

[8]ページ先頭

©2009-2025 Movatter.jp