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
Get __class__ keyword works without AST modification #734
Get __class__ keyword works without AST modification #734
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. There seems to be some sort of binding issue. For whatever reason the following example returns the function instead of the class.
class test(object):
def test(self):
def test2():
return __class__
return test2()
assert test().test() == test
@@ -229,6 +231,8 @@ internal class DebugProxy { | |||
} | |||
} | |||
|
|||
internal CodeContext GrandParentContext => _maybegrandparent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe drop the _maybegrandparent
field and use an auto-implemented property?
internal CodeContext GrandParentContext { get; }
|
||
/// <summary> | ||
/// Creates a new CodeContext which is backed by the specified Python dictionary. | ||
/// </summary> | ||
public CodeContext(PythonDictionary/*!*/ dict, ModuleContext/*!*/ moduleContext) { | ||
public CodeContext(PythonDictionary/*!*/ dict, ModuleContext/*!*/ moduleContext, CodeContext maybegrandparent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a concept that should be exposed publicly? Maybe add an internal constructor overload instead?
Thanks for the PR! Closing this since the issue has been resolved by #1087 |
Hi, this resolves #723.
As the subject says, the AST modification (introduced in #721) has been removed.
Changes are...
GetGrandParentContextFromFunction()
to make__class__
handling code works. c.f.) FunctionDefinition.cs