-
Notifications
You must be signed in to change notification settings - Fork 676
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
Exception while editing IronPython code #697
Comments
Also, while rebuilding a combined C# and IronPython solution, I occasionally get a total freeze of VS with a dialog message "Microsoft Visual Studio Express 2013 for Windows Desktop has stopped working" with the following problem signature that is also a cast exception. Nothing has been added to the activity log. Problem signature: |
That's totally okay, the stack trace is more than enough information for us here. (The best way to provide a big text file on GitHub is to create a https://gist.github.com/ and link to it.) |
We should also backport this fix to 2.1.1. |
So I started fixing this but have to get onto something else right now. Here are the changes I've made so far, and there are a lot more unconditional casts that now need to be checked properly (I assume IronPython 2.7.5 changed the base types of some types). diff --git a/Python/Product/IronPython/Interpreter/RemoteInterpreter.cs b/Python/Product/IronPython/Interpreter/RemoteInterpreter.cs
--- a/Python/Product/IronPython/Interpreter/RemoteInterpreter.cs
+++ b/Python/Product/IronPython/Interpreter/RemoteInterpreter.cs
@@ -702,7 +702,18 @@
internal PythonMemberType GetPythonTypeMemberType(ObjectIdentityHandle pythonType) {
return CallAndHandle(() => {
- var value = (PythonType)Unwrap(pythonType);
+ var pt = Unwrap(pythonType);
+ var value = pt as PythonType;
+ if (value == null) {
+ if (pt is BuiltinFunction) {
+ return PythonMemberType.Function;
+ }
+ if (pt is BuiltinMethodDescriptor) {
+ return PythonMemberType.Method;
+ }
+ Debug.Fail("Unhandled IronPython type: " + pt.GetType().FullName);
+ return PythonMemberType.Unknown;
+ }
var type = value.__clrtype__();
if (type.IsEnum) {
return PythonMemberType.Enum;
@@ -716,8 +727,8 @@
internal bool PythonTypeHasNewOrInitMethods(ObjectIdentityHandle pythonType) {
return CallAndHandle(() => {
- var value = (PythonType)Unwrap(pythonType);
- return PythonTypeHasNewOrInitMethods(value);
+ var value = Unwrap(pythonType) as PythonType;
+ return value != null && PythonTypeHasNewOrInitMethods(value);
}, false);
} |
I do hope this is fixed soon. As my project is growing the constant freezing of VS during compilation is getting tedious to the point of being almost unusable. |
Having looked deeper into this, I don't think handling all the types is actually the correct approach. It looks more like we're creating an internal IPythonType GetTypeFromType(ObjectIdentityHandle type) {
if (type.IsNull) {
return null;
}
lock (this) {
IMember res;
if (!_members.TryGetValue(type, out res)) {
_members[type] = res = new IronPythonType(this, type);
}
return res as IPythonType;
}
} But it's called from a lot of places. @DinoV might be able to track down the incorrect one faster than I can. |
Fixes #697 Exception while editing IronPython code
VS2013 Desktop Express, IronPython 2.7.5, PTVS 2.2.30718.00
Occasionally while editing IronPython code I get a modal MessageBox telling me that
"An exception has been encountered. This may be caused by an extension."
The relevant entry in the VS activity log starts
System.InvalidCastException: Unable to cast object of type 'IronPython.Runtime.Types.BuiltinFunction' to type 'IronPython.Runtime.Types.PythonType'. at
Microsoft.IronPythonTools.Interpreter.RemoteInterpreter.<>c__DisplayClass64_0.b__0() at Microsoft.IronPythonTools.Interpreter.RemoteInterpreter.CallAndHandle[T](Func`1 action, T defaultValue) at
Microsoft.IronPythonTools.Interpreter.RemoteInterpreter.GetPythonTypeMemberType(ObjectIdentityHandle pythonType) at
Microsoft.IronPythonTools.Interpreter.RemoteInterpreterProxy.GetPythonTypeMemberType(ObjectIdentityHandle value) at
Microsoft.IronPythonTools.Interpreter.RemoteInterpreterProxy.GetPythonTypeMemberType(ObjectIdentityHandle value) at
Microsoft.IronPythonTools.Interpreter.IronPythonType.get_MemberType() at
Microsoft.PythonTools.Analysis.Values.BuiltinClassInfo.get_MemberType() at
Microsoft.PythonTools.Analysis.Values.SpecializedNamespace.get_MemberType() at
Microsoft.PythonTools.Analysis.MemberResult.GetMemberType() at
Microsoft.PythonTools.Analysis.MemberResult.get_MemberType() at
Microsoft.PythonTools.Intellisense.CompletionAnalysis.PythonCompletion(IGlyphService service, MemberResult memberResult) at
...
Unfortunately I can't see any way of attaching the activity log here.
The text was updated successfully, but these errors were encountered: