Skip to content

Python 3.11+ partial workaroundΒ #172

@perkinslr

Description

@perkinslr

Description

I need the ability to obtain function source code at runtime for various introspection purposes. Since Python 3.9+, and Python3.11 even more, cannot be easily decompiled, I cheated. The results are here.

While properly decompiling code is needed for dynamically generated code, complex template logic, and when you don't have the original source code available, sometimes it's sufficient to simply automate fetching the relevant lines of source code out of the source file.

The fake decompiler is zlib licensed, so you're welcome to hoist it into your own stuff if you like, or just link to it on the readme. Hopefully it will be of some use.

Note that I'm out of time to implement recreating the function signature to support lambdas better. It should take maybe half an hour to do, just need to extract the arguments and stringify them suitably. Faking signatures works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions