Skip to content

Import hook clean-up #350

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 2, 2017
Merged

Import hook clean-up #350

merged 2 commits into from
Feb 2, 2017

Conversation

vmuriart
Copy link
Contributor

@vmuriart vmuriart commented Feb 1, 2017

What does this implement/fix? Explain your changes.

Refactor importhook.cs

Does this close any currently open issues?

I wish...

#elif PYTHON2
Runtime.XIncref(root.pyHandle); // we are using the module two times
Runtime.PyDict_SetItemString(dict, "CLR", root.pyHandle);
Runtime.PyDict_SetItemString(dict, "clr", root.pyHandle);
py_clr_module = root.pyHandle; // Alias handle for PY2/PY3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@filmor Since you just worked on this, any reason this wouldn't work or is a bad idea?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, this should work fine, IMO.

@codecov-io
Copy link

Codecov Report

Merging #350 into master will increase coverage by -0.03%.

@@            Coverage Diff             @@
##           master     #350      +/-   ##
==========================================
- Coverage   61.65%   61.62%   -0.03%     
==========================================
  Files          61       61              
  Lines        5286     5280       -6     
  Branches      893      892       -1     
==========================================
- Hits         3259     3254       -5     
  Misses       1806     1806              
+ Partials      221      220       -1
Impacted Files Coverage Δ
src/runtime/importhook.cs 75.88% <66.66%> (-0.31%)

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 a12b2b2...c63853d. Read the comment docs.

#endif
py_import = Runtime.PyObject_GetAttrString(mod, "__import__");
Copy link
Member

Choose a reason for hiding this comment

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

You could instead use PyEval_GetBuiltins() on both Py2 and 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saw this comment after I merged it in 😞

#elif PYTHON2
Runtime.XIncref(root.pyHandle); // we are using the module two times
Runtime.PyDict_SetItemString(dict, "CLR", root.pyHandle);
Runtime.PyDict_SetItemString(dict, "clr", root.pyHandle);
py_clr_module = root.pyHandle; // Alias handle for PY2/PY3
Copy link
Member

Choose a reason for hiding this comment

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

Nope, this should work fine, IMO.

@vmuriart vmuriart merged commit 0e74f86 into pythonnet:master Feb 2, 2017
vmuriart added a commit that referenced this pull request Feb 2, 2017
@vmuriart vmuriart deleted the import-hook branch February 2, 2017 16:56
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.

3 participants