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

Explicit marshalling of Py_SetPythonHome string. by leomeuk · Pull Request #186 · pythonnet/pythonnet · GitHub

Repository navigation

Explicit marshalling of Py_SetPythonHome string. - #186

Closed
leomeuk wants to merge 2 commits into
pythonnet:developfrom
leomeuk:develop
Closed

leomeuk wants to merge 2 commits into
pythonnet:developfrom
leomeuk:develop

Conversation

leomeuk commented Mar 13, 2016

Copy link
Copy Markdown

Updates as described in #179.

I did look at calling Marshal.FreeHGlobal() in the PythonEngine.Shutdown() method after the call to shutdown Python is made, however it looks as though Python is doing the required memory tidy up.

Unit test has been created but is written to assume Python is installed at C:\Python27.

Assert.AreEqual(PythonEngine.PythonHome, homePath);
}
}
}

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

@leomeuk you can get python path using this c# code which requires python interpreter:

dynamic pyos = Py.Import("os");
string homepath = pyos.path.dirname(pyos.path.dirname(pyos.__file__));

Note that PythonEngine.PythonPath is also "broken" like PythonEngine.PythonHome:

> #r "C:\Python\Python27\Lib\site-packages\Python.Runtime.dll"
> using Python.Runtime;
> PythonEngine.Initialize()
> PythonEngine.PythonPath
Hosting process exited with exit code -1073740940.
Loading context from 'CSharpInteractive.rsp'.

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

Updating this PR and noticed this comment. I documented the issue with PythonEngine.PythonPath on #414. All the get functions were broken on 64bit python.

Copy link
Copy Markdown
Contributor

@leomeuk I added the comment inline in code, once your commit is ready please git squash it into one logical unit (commit) per contributing guidelines. Thanks!

Copy link
Copy Markdown
Contributor

Looks like this would leak the allocated string if python home was set twice? Is it safe to have Python deallocate the string allcated in .net? What happens if you deallocate it in Shutdown and set pythonhome to NULL, would that stop Python from trying to also deallocate the string?

Copy link
Copy Markdown
Contributor

@leomeuk can you please make a pull request against master branch? develop branch is deleted.

Copy link
Copy Markdown
Contributor

@tonyroberts I'm not worried about leaking just 1 or 2 strings, this fix is more important than a small leak.

vmuriart mentioned this pull request Mar 3, 2017
2 tasks done
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