Bug 8226 - obfuscator doesn't support "nonlocal"
Summary: obfuscator doesn't support "nonlocal"
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Build system (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.16.0
Assignee: Pierre Ossman
URL:
Keywords: linma_tester, prosaic
Depends on:
Blocks:
 
Reported: 2023-09-14 09:40 CEST by Pierre Ossman
Modified: 2023-09-18 13:51 CEST (History)
1 user (show)

See Also:
Acceptance Criteria:
MUST: * nonlocal constructs should work correctly after obfuscation SHOULD: * nonlocal variables should be obfuscated * there should be automatic tests for nonlocal * upstream should have a patch


Attachments

Description Pierre Ossman cendio 2023-09-14 09:40:03 CEST
Python 3 added the "nonlocal" keyword to control scoping. Unfortunately, our obfuscator isn't aware of this and isn't managed to handle naming properly:

RuntimeError: Overlooked symbol 'call' on line 277 column 17
Comment 1 Pierre Ossman cendio 2023-09-14 10:47:42 CEST
Patch fixed and sent upstream:

https://github.com/astrand/pyobfuscate/pull/27
Comment 3 Pierre Ossman cendio 2023-09-14 12:33:32 CEST
Committed and done.

> MUST:
> 
>  * nonlocal constructs should work correctly after obfuscation

Yup. Works with code in product.

> SHOULD:
> 
>  * nonlocal variables should be obfuscated

They are indeed.

>  * there should be automatic tests for nonlocal

There are. Based roughly on what existing tests we had for local variables and global variables.

>  * upstream should have a patch

Yup. See above.
Comment 4 Linn cendio 2023-09-18 13:51:56 CEST
Tested building server-bundle after upgrading cendio-build-python3-pyobfuscate-x86_64 to version 0.3-7.g6731c8a, and can confirm that nonlocal variable no longer cause the RuntimeError seen in comment 0.

MUST:
 ✅ nonlocal constructs should work correctly after obfuscation
They do. Tested by adding a test function that wrote the value of the nonlocal variable in the log. The variable had the expected value.

SHOULD:
 ✅ nonlocal variables should be obfuscated
They are.

 ✅ there should be automatic tests for nonlocal
Yes, there are unit tests included in the patch for upstream.

 ✅ upstream should have a patch
Patch is sent as has been applied to the project.


Also checked the code changes in our code and for the upstream patch, looks good.

Note You need to log in before you can comment on or make changes to this bug.