-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8607c4
commit 0a70030
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from refinery.units import Unit | ||
|
||
import importlib | ||
import marshal | ||
|
||
|
||
class pym(Unit): | ||
""" | ||
Converts Python-Marshaled code objects to the PYC (Python Bytecode) format. If it is an | ||
older Python version, you can use the `refinery.pyc` unit to then decompile the code, but | ||
for more recent versions a separate Python decompiler will be required. | ||
WARNING: This unit will invoke the `marshal.loads` function, which may be unsafe. Please | ||
refer to the official Python documentation for more details. | ||
""" | ||
|
||
def process(self, data): | ||
# https://stackoverflow.com/a/73454818 | ||
return importlib._bootstrap_external._code_to_timestamp_pyc(marshal.loads(data)) |