Skip to content

Commit

Permalink
adds pym unit
Browse files Browse the repository at this point in the history
  • Loading branch information
huettenhain committed Oct 21, 2024
1 parent e8607c4 commit 0a70030
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions refinery/units/formats/pym.py
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))

0 comments on commit 0a70030

Please sign in to comment.