python反编译dll_python - 是否可以反编译.dll / .pyd文件以提取Python源代码? - 堆栈内存溢出...

通过错误处理可以发现,.pyd文件在发生错误时会显示源代码行,包括注释。这表明源代码信息在编译后的文件中存在,但直接反编译可能并不完全可行。当原始.pyx文件缺失时,错误信息中不再显示源代码详情。
摘要由CSDN通过智能技术生成

我不同意接受的答案,似乎是的,即使在.pyd也可以访问源代码的内容。

让我们看一下如果出现错误会发生什么:

1)创建此文件:

whathappenswhenerror.pyx

A = 6

print 'hello'

print A

print 1/0 # this will generate an error

2)使用python setup.py build编译它:

setup.py

from distutils.core import setup

from Cython.Build import cythonize

setup(ext_modules = cythonize("whathappenswhenerror.pyx"), include_dirs=[])

3)现在在标准python文件中导入.pyd文件:

testwhathappenswhenerror.py

import whathappenswhenerror

4)让我们用python testwhathappenswhenerror.py运行它。 这是输出:

hello

6

Traceback (most recent call last):

File "D:\testwhathappenswhenerror.py", line 1, in

import whathappenswhenerror

File "whathappenswhenerror.pyx", line 4, in init whathappenswhenerror (whathappe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值