FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Binary substitution of Python.Runtime.dll becomes safe. by dmitriyse · Pull Request #456 · pythonnet/pythonnet · GitHub

Repository navigation

Binary substitution of Python.Runtime.dll becomes safe. - #456

Merged
filmor merged 7 commits into
pythonnet:masterfrom
dmitriyse:master
Jul 10, 2017
Merged

filmor merged 7 commits into
pythonnet:masterfrom
dmitriyse:master

Conversation

Copy link
Copy Markdown
Contributor

What does this implement/fix? Explain your changes.

Public constants replaced to static readonly fields. Relaxed platform binding.
C# Compiler copies constants of assembly. This may cause to errors when
code was compiled with reference to one build of Python.Runtime.dll and then
after compile other build of Python.Runtime.dll is used.
...

Does this close any currently open issues?

No, but it work towards cross-platform nuget package #165
...

Any other comments?

...

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

Public constants replaced to static readonly fields. Relaxed platform binding.

Copy link
Copy Markdown

@dmitriyse, thanks! @vmuriart, @hsoft, @brianlloyd, @tiran and @tonyroberts, please review this.

codecov Bot commented Apr 25, 2017 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

Merging #456 into master will decrease coverage by 0.03%.
The diff coverage is 75%.

@@            Coverage Diff             @@
##           master     #456      +/-   ##
==========================================
- Coverage   77.16%   77.12%   -0.04%     
==========================================
  Files          65       65              
  Lines        5543     5547       +4     
  Branches      889      889              
==========================================
+ Hits         4277     4278       +1     
- Misses        978      981       +3     
  Partials      288      288
Flag Coverage Δ
#setup_linux 75.71% <ø> (ø) ⬆️
#setup_windows 76.47% <75%> (-0.04%) ⬇️
Impacted Files Coverage Δ
src/runtime/CustomMarshaler.cs 69.86% <100%> (ø) ⬆️
src/runtime/runtime.cs 90.58% <66.66%> (-1.05%) ⬇️

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 87eb102...77b49a2. Read the comment docs.

filmor commented Apr 25, 2017

Copy link
Copy Markdown
Member

Why do you rename all of those fields?

Copy link
Copy Markdown
Contributor Author

Python.Runtime.dll consumers should not use public constants that have different values in different builds (platform, python version, etc). Otherwise when Python.Runtime.dll replaced in binary distribution, will have mismatch between constants values used in replaced Python.Runtime.dll and constant values copied to assemblies that referenced non replaced version of Python.Runtime.dll at compile time.

So we needs to replace constants to static read only fields.

Also we needs to honor source code backward compatibility and produce no any breaking change in an existing consumer source code.

So the only way to satisfy both "source code backward compatibility" and const->fields change is to rename constants and make them internal.

den-run-ai closed this Apr 26, 2017
den-run-ai reopened this Apr 26, 2017

Copy link
Copy Markdown
Contributor

closed and re-opened to check on Travis CI again

filmor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Also, you should probably already add the static properties, if possible.

Comment thread src/runtime/runtime.cs Outdated
private const string PyUnicodeEntryPoint = "PyUnicodeUCS4_";
#elif UCS2
public const int UCS = 2;
public const int _UCS = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You only changed one branch of the #if here (same further down for _pyversion etc.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@filmor do you mean that only one if-branch is changed to from public to internal for _UCS? @dmitriyse can you please address this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I fixed this and some similar problems.

Comment thread src/runtime/runtime.cs Outdated
public const string pyversion = "3.7";
public const string pyver = "37";
public const string _pyversion = "3.7";
public const string _pyver = "37";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

all these _pyver* above should be internal @dmitriyse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, I will fix this soon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Fixed.

filmor commented Jul 3, 2017 •
edited
Loading

Copy link
Copy Markdown
Member

@dmitriyse Are you going to continue on this branch? I fear we have to close it at some point as it will have deviated too far from master.

Copy link
Copy Markdown
Contributor Author

I will try to do update it tomorrow. Or we will close this branch.

den-run-ai self-requested a review July 5, 2017 04:54
Comment thread src/runtime/runtime.cs Outdated
// We needs to replace all public constants to static readonly fields to allow
// binary substitution of different Python.Runtime.dll builds in a target application.

public static readonly int UCS = _UCS;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please change these to properties. Allows us to make this fully dynamic in the future without breaking user code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, I will replace them to properties.
But I did not understand this:

fully dynamic in the future without breaking user code.

Probably I need some example.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If we ever want to have a single DLL for all platforms and Python versions, the values of pyversion or UCS will have to be evaluated at runtime on startup, that's what I meant.

Comment thread src/runtime/runtime.cs Outdated
// binary substitution of different Python.Runtime.dll builds in a target application.

public readonly string pyversion = _pyversion;
public readonly string pyver = _pyver;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These two too.

filmor merged commit 25e66f0 into pythonnet:master Jul 10, 2017
testrunner123 pushed a commit to testrunner123/pythonnet that referenced this pull request Sep 22, 2017
* Binary substitution of Python.Runtime.Dll becomes safe.
* Public constants replaced to static readonly fields. Relaxed platform binding.
* Static readonly fields (related to build depented values) replaced by properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL