QQuick / Opy

Obfuscator for Python
Other
364 stars 61 forks source link

When debugging opy.py the "addExternalNames" functions hangs the execution #14

Closed andimarafioti closed 7 years ago

andimarafioti commented 7 years ago

I'm using the latest version of Pycharm and I'm getting this error when I debug opy.py:

C:/Users/Dev5/Documents/myProject/opy.py:360: RuntimeWarning: tp_compare didn't return -1 or -2 for exception

For some reason, this hangs the execution. The error comes from the check:

if anObject in externalObjects:
    return

in the addExternalNames function. A simple way to fix this is to check in the function if the argument is Hashable. If it is not, then it shouldn't be in externalObjects so I return.

def addExternalNames(anObject):
    if isinstance(anObject, collections.Hashable):
        return
    if anObject in externalObjects:
        return

I don't know why this bug exists though and this is simply a patch to avoid something that shouldn't happen in the first place.

JdeH commented 7 years ago

Hi,

No idea why this occurs. If I look at #15, it seems like the patch won't work, so I'll close it for now. Feel free to reopen if I misunderstood.

Kind regards Jacques

andimarafioti commented 7 years ago

Hi,

I think this issue should be open because there is no obvious fix (see https://github.com/QQuick/Opy/issues/15). Can you debug the execution correctly? I tested it in two machines but they have a pretty similar configuration. I agree https://github.com/QQuick/Opy/issues/15 should be closed as that issue only comes from the quick fix I proposed here.

Regards Andres

JdeH commented 7 years ago

You're right, I'll reopen!

JdeH commented 7 years ago

By the way, this "hanging" is probably infinite recursion. Seems that the comparison as part of the 'in' operator fails.

If I understand you right, this error only surfaces when DEBUGGING, so not during normal execution? I can imagine the debugger comparing types in an unorthodox way, which may fail. Should you discover anything further about this I am very interested.

JdeH commented 7 years ago

Really seems to be a debugger thing. Can't reproduce it on the command line. So I'll once again close it. If anyone can reproduce it outside the debugger, feel free to reopen.

vkhazin commented 4 years ago

I am facing the issue outside of debugger running on Windows 10 64bit from PowerShell, had to kill the process externally: https://github.com/vkhazin/python-obfuscate/blob/master/package.ps1#L24