mauricelambert/PyObfuscator

Got Unexpected Value Error, or File doe not exists error

key6oardWarrior opened this issue · 5 comments

On Python 3.11.1 when attempting to obfuscat using the command "PyObfuscator [file path]" I got this error message:
"ValueError: Unexpected node inside JoinedStr, <ast.Call object at [memory address]>"

When using any other command listed in the README.md I got an error telling me that the file does not exists, but I copied and pasted the file path from my file explorer.

Thanks for opening this issue.

Can you reproduce this error with few lines, please ? Because i can't see the source of the bug.

I think the ValueError: Unexpected node inside JoinedStr is an error with format string. Maybe PyObfuscator try to obfuscate some things inside a format string... I will try to get this error on a script.

I get exception (ValueError: Unexpected node inside JoinedStr, <ast.Call object at 0x0> and python 3.11.1) with these lines:

a = {'def': 25}
b = '*'
c = 8
f'0x{a["def"]:{b}>{c}x}'
a = {'def': 25}
b = '*'
c = 8
f'0x{a["def"]}'
b = '*'
c = 8
f'0x{c:{b}>{c}x}'
a = {'def': 25}
f'0x{a}'
from ast import *
print(dump(parse("f'0x{a}'"), indent=4))
Module(
    body=[
        Expr(
            value=JoinedStr(
                values=[
                    Constant(value='0x'),
                    FormattedValue(
                        value=Name(id='a', ctx=Load()),
                        conversion=-1)]))],
    type_ignores=[])

Problem is in line 757 and line 777:

def visit_Constant(self, astcode: Constant) -> Call:
    ...
    return Call() 

And Python can't generate code for ast.Call as format string constant.

Issue is fixed and the new version is deploy on pypi.