Skip to content
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

fix: can not run in Python repl #139

Merged
merged 4 commits into from Jan 17, 2023
Merged

fix: can not run in Python repl #139

merged 4 commits into from Jan 17, 2023

Conversation

yihong0618
Copy link
Contributor

this pr fix can not run greenplumpython in python repl
see issue python/cpython#57129

@@ -268,9 +268,21 @@ def create_in_db(self, db: Database) -> None:
for param in func_sig.parameters.values()
]
)
# make inspect.getsource can run in Python REPL(IPython do not have this issue)
# CPython issue https://github.com/python/cpython/issues/57129
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts after leaning this magical library:

Suggested change
# CPython issue https://github.com/python/cpython/issues/57129
# CPython issue https://github.com/python/cpython/issues/57129
# TODO: in the future, we might want to use `dill.dumps(func, recurse=True)`
# to send the function to the DBMS with dependencies like imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that will be wonderful we will use this library more not only the getsource things

# CPython issue https://github.com/python/cpython/issues/57129
try:
source: str = inspect.getsource(self._wrapped_func)
# if run inspect.getsource(func) in REPL will rasie IOError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# if run inspect.getsource(func) in REPL will rasie IOError
# if run inspect.getsource(func) in REPL will raise IOError

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.

None yet

3 participants