René's URL Explorer Experiment


Title: MSTests failing when importing a module with imports · Issue #262 · pythonnet/pythonnet · GitHub

Open Graph Title: MSTests failing when importing a module with imports · Issue #262 · pythonnet/pythonnet

X Title: MSTests failing when importing a module with imports · Issue #262 · pythonnet/pythonnet

Description: Very simple to reproduce: In the Python.EmbeddingTests project (I am using master branch): Add reference to MSTest (Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.0.0) Convert pyimport from NUnit to MSTest: remove NUnit I...

Open Graph Description: Very simple to reproduce: In the Python.EmbeddingTests project (I am using master branch): Add reference to MSTest (Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.0.0) Convert pyimp...

X Description: Very simple to reproduce: In the Python.EmbeddingTests project (I am using master branch): Add reference to MSTest (Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.0.0) Convert pyimp...

Opengraph URL: https://github.com/pythonnet/pythonnet/issues/262

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MSTests failing when importing a module with imports","articleBody":"Very simple to reproduce:\n\nIn the Python.EmbeddingTests project (I am using master branch):\n- Add reference to MSTest (Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.0.0)\n- Convert pyimport from NUnit to MSTest:\n  - remove NUnit Import, add using Microsoft.VisualStudio.TestTools.UnitTesting\n  - replace attributes with MStest attributes (TestClass, TestInitialise, TestCleanup, TestMethod)\n- Running TestDottedName works as expected.\n- Edit one.py and add `import numpy as np` as first line\n- Run TestDottedName should work first time\n- Run TestDottedName again, now it fails with:\n\n```\n\nTest method Python.EmbeddingTest.PyImportTest.TestDottedName threw exception: \nSystem.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.\n```\n\nThis error is also being shown in my ASP.Net Web API application on restart so I hope a solution will solve both MSTest and ASP.Net.\n\nFurther Information: Full version of pyimport.cs after edits is:\n\n```\nusing System;\nusing System.Reflection;\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\nusing Python.Runtime;\n\nnamespace Python.EmbeddingTest\n{\n    [TestClass]\n    public class PyImportTest\n    {\n        private IntPtr gs;\n\n        [TestInitialize]\n        public void SetUp()\n        {\n            string path = @\"c:\\dev\\libs\\Anaconda3\\envs\\python2;\" + Environment.GetEnvironmentVariable(\"PATH\", EnvironmentVariableTarget.Machine);\n            Environment.SetEnvironmentVariable(\"PATH\", path, EnvironmentVariableTarget.Process);\n            Environment.SetEnvironmentVariable(\"PYTHONHOME\", @\"c:\\dev\\libs\\Anaconda3\\envs\\python2\", EnvironmentVariableTarget.Process);\n            Environment.SetEnvironmentVariable(\"PYTHONPATH \", @\"c:\\dev\\libs\\Anaconda3\\envs\\python2\\Lib\", EnvironmentVariableTarget.Process);\n\n            PythonEngine.Initialize();\n            gs = PythonEngine.AcquireLock();\n\n            //string here = Environment.CurrentDirectory;\n            //trunk\\pythonnet\\src\\embed_tests\\bin\\x86\\DebugWin\n\n            /*\n             * Append the tests directory to sys.path\n             * using reflection to circumvent the private modifires placed on most Runtime methods.\n             */\n            const string s = @\"../../../../tests\";\n\n            Type RTClass = typeof(Runtime.Runtime);\n\n            /* pyStrPtr = PyString_FromString(s); */\n            MethodInfo PyString_FromString = RTClass.GetMethod(\"PyString_FromString\",\n                BindingFlags.NonPublic | BindingFlags.Static);\n            object[] funcArgs = new object[1];\n            funcArgs[0] = s;\n            IntPtr pyStrPtr = (IntPtr)PyString_FromString.Invoke(null, funcArgs);\n\n            /* SysDotPath = sys.path */\n            MethodInfo PySys_GetObject = RTClass.GetMethod(\"PySys_GetObject\",\n                BindingFlags.NonPublic | BindingFlags.Static);\n            funcArgs[0] = \"path\";\n            IntPtr SysDotPath = (IntPtr)PySys_GetObject.Invoke(null, funcArgs);\n\n            /* SysDotPath.append(*pyStrPtr) */\n            MethodInfo PyList_Append = RTClass.GetMethod(\"PyList_Append\", BindingFlags.NonPublic | BindingFlags.Static);\n            funcArgs = new object[] { SysDotPath, pyStrPtr };\n            int r = (int)PyList_Append.Invoke(null, funcArgs);\n        }\n\n        [TestCleanup]\n        public void TearDown()\n        {\n            PythonEngine.ReleaseLock(gs);\n            PythonEngine.Shutdown();\n        }\n\n        [TestMethod]\n        public void TestDottedName()\n        {\n            PyObject module = PythonEngine.ImportModule(\"PyImportTest.test.one\");\n            Assert.IsNotNull(module, \"\u003e\u003e\u003e  import PyImportTest.test.one  # FAILED\");\n        }\n    }\n}\n```\n","author":{"url":"https://github.com/gatapia","@type":"Person","name":"gatapia"},"datePublished":"2016-09-07T23:12:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/262/pythonnet/issues/262"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:da539ba2-59b5-69a5-a035-b50d33d746c1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC778:32FE0E:140C494:1C21D15:6970D117
html-safe-nonce15a3e879df877b0600e61c3f62c6d26e38d9599ae572c376e8d6077e387f5ec9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzc4OjMyRkUwRToxNDBDNDk0OjFDMjFEMTU6Njk3MEQxMTciLCJ2aXNpdG9yX2lkIjoiODQ5MzE1ODg1MzA1NzIzNzI3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8cbcfa80d26d261af3b174f7270c34f5f743a6217a5b9fb7928714eb1da21108
hovercard-subject-tagissue:175628495
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/262/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a2f32c8530594686c0b83157071af1e3fdb9a4075a03a5a00962f8e85a103f6a/pythonnet/pythonnet/issues/262
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a2f32c8530594686c0b83157071af1e3fdb9a4075a03a5a00962f8e85a103f6a/pythonnet/pythonnet/issues/262
og:image:altVery simple to reproduce: In the Python.EmbeddingTests project (I am using master branch): Add reference to MSTest (Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.0.0) Convert pyimp...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegatapia
hostnamegithub.com
expected-hostnamegithub.com
None034aaee9edccd455c18591b13122193c6e12dc773e8a203be73abe934f3e3a72
turbo-cache-controlno-preview
go-importgithub.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git
octolytics-dimension-user_id6050430
octolytics-dimension-user_loginpythonnet
octolytics-dimension-repository_id14748123
octolytics-dimension-repository_nwopythonnet/pythonnet
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14748123
octolytics-dimension-repository_network_root_nwopythonnet/pythonnet
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release52d1d534d0b88c64972e852deb460d09b433b8b2
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/pythonnet/pythonnet/issues/262#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F262
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F262
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pythonnet%2Fpythonnet
Reloadhttps://github.com/pythonnet/pythonnet/issues/262
Reloadhttps://github.com/pythonnet/pythonnet/issues/262
Reloadhttps://github.com/pythonnet/pythonnet/issues/262
pythonnet https://github.com/pythonnet
pythonnethttps://github.com/pythonnet/pythonnet
Notifications https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Fork 770 https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Star 5.4k https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Code https://github.com/pythonnet/pythonnet
Issues 155 https://github.com/pythonnet/pythonnet/issues
Pull requests 18 https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects 0 https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/pythonnet/pythonnet/security
Please reload this pagehttps://github.com/pythonnet/pythonnet/issues/262
Insights https://github.com/pythonnet/pythonnet/pulse
Code https://github.com/pythonnet/pythonnet
Issues https://github.com/pythonnet/pythonnet/issues
Pull requests https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security https://github.com/pythonnet/pythonnet/security
Insights https://github.com/pythonnet/pythonnet/pulse
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/262
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/262
#365https://github.com/pythonnet/pythonnet/pull/365
MSTests failing when importing a module with importshttps://github.com/pythonnet/pythonnet/issues/262#top
#365https://github.com/pythonnet/pythonnet/pull/365
2.3.0https://github.com/pythonnet/pythonnet/milestone/5
https://github.com/gatapia
https://github.com/gatapia
gatapiahttps://github.com/gatapia
on Sep 7, 2016https://github.com/pythonnet/pythonnet/issues/262#issue-175628495
2.3.0https://github.com/pythonnet/pythonnet/milestone/5
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.