-
Notifications
You must be signed in to change notification settings - Fork 26
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
Allow users to run Python code from a string #340
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.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
@@ -144,4 +145,34 @@ public bool IsDisposed() | |||
{ | |||
return disposedValue; | |||
} | |||
|
|||
public PyObject Execute(string code) |
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.
The method does not handle potential exceptions that could be thrown by CPythonAPI.PyRun_String. Consider adding exception handling to catch and log errors.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
} | ||
} | ||
|
||
public PyObject Execute(string code, IDictionary<string, PyObject> locals) |
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.
The method does not handle potential exceptions that could be thrown by CPythonAPI.PyRun_String. Consider adding exception handling to catch and log errors.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
} | ||
} | ||
|
||
public PyObject Execute(string code, IDictionary<string, PyObject> globals, IDictionary<string, PyObject> locals) |
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.
The method does not handle potential exceptions that could be thrown by CPythonAPI.PyRun_String. Consider adding exception handling to catch and log errors.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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.
While the code itself looks fine I question the general value of this, as what role is .NET really playing here? Like, you really need to know the inputs and outputs beforehand so that you can read/write them, or you just pass through arbitrary code with .NET not really "touching" anything at either end (which seems inherently dangerous)
This would be used for edge cases, like running complicated expressions on an object that you've got back from CSnakes, or dynamically running a bit of interpreted code on the module. |
Yeah, I read the issue so I "get" the use-case but it's the kind of thing I wonder if CSnakes is the best tool for, since .NET isn't exactly idea for a scripting environment. |
Implements #290
Adds two different types of API:
1+1
) and returns the result