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

latexify form a function defined in an exec will result in OSError #107

Closed
huu4ontocord opened this issue Nov 15, 2022 · 3 comments
Closed
Assignees
Labels
help wanted Extra attention is needed

Comments

@huu4ontocord
Copy link

exec("""
def solve(a, b, c):
return (-b + math.sqrt(b**2 - 4ac)) / (2*a)
""")

lat = latexify.get_latex(solve)

Will result in: OSError: could not extract source code

@odashi
Copy link
Collaborator

odashi commented Nov 15, 2022

Thanks for reporting, but I don't think this is easily fixable as the dynamic object doesn't remember its original source.

It may require decompiling the underlying bytecodes into some corresponding source or AST. Since bytecodes lack the original representation of the source code, the result could be distant from the original even if we could restore it.

Maybe the possible workaround is to provide a functionality that takes the source code directly, as in #108 .

@odashi odashi added the help wanted Extra attention is needed label Nov 15, 2022
@odashi
Copy link
Collaborator

odashi commented Nov 15, 2022

I will keep this issue opened for a while to gather some ideas.

@odashi odashi removed the bug: minor label Nov 15, 2022
@huu4ontocord
Copy link
Author

Yes. I figured that the solution was to go straight from str to latex :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants