0x3C50 / pyobf2

An in-place obfuscator for python 3.11
BSD 3-Clause "New" or "Revised" License
53 stars 8 forks source link

nonlocal and renamer #18

Closed dekrypted closed 9 months ago

dekrypted commented 10 months ago

for example:

def func1():
   var1 = 0
   def func2():
       nonlocal var1

and then rename variables, it might look like this

def method0():
   gwnduagdugudvsbau = 0
   def method1():
       nonlocal var1

basically renamer skips over a nonlocal

0x3C50 commented 10 months ago

dawg this is why i fucking hate python what the fuck is "nonlocal" even supposed to mean????

dekrypted commented 10 months ago

for some reason when wrapping functions within functions, you have to nonlocal a variable from the parent function to access it in the child function, like global, its python what do u expect

raydrak64 commented 9 months ago

After 600,000 lines of Python AI code have I ever used a function within a function. Never seen 3rd party modules do it either. By the time you get to that point you would create a class. So, I ask... Why?

dekrypted commented 9 months ago

After 600,000 lines of Python AI code have I ever used a function within a function. Never seen 3rd party modules do it either. By the time you get to that point you would create a class. So, I ask... Why?

for a VERY specific case using WinAPI in where there is pretty much no other way to go about it... using c functions in python especially winapi with all the types is kind of a pain in the ass... and the hardcoded nature of it makes it pretty much unavoidable

0x3C50 commented 9 months ago

there's gotta be a different way you can do what you want to do. i have never even fucking heard of a "nonlocal" keyword being used anywhere for any reason. i'm probably not going to "fix" this since the project is more or less abandoned now, i have better things to do than to make sense of python's stupid design decisions. this language was created and will stay in hell forever

dekrypted commented 9 months ago

lmao i agree. no need to fix, i found a kinda solution (althought its kinda ugly) but thanks anyway