Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] static dictionaries will cause Int/Str not callable error once compiled in Python>3.12 #1987

Open
Apprisco opened this issue Nov 14, 2024 · 11 comments
Labels

Comments

@Apprisco
Copy link

class C:
    vk={'mclick':4,'backspace':8,'tab':9,'clear':12,'enter':13,'shift':16,'ctrl':17,'alt':18,'pause':19,'caps_lock':20,'esc':27,'spacebar':32,'page_up':33,'page_down':34,'end':35,'home':36,'left_arrow':37,'up_arrow':38,'right_arrow':39,'down_arrow':40,'select':41,'print':42,'execute':43,'print_screen':44,'ins':45,'del':46,'help':47,'0':48,'1':49,'2':50,'3':51,'4':52,'5':53,'6':54,'7':55,'8':56,'9':57,'a':65,'b':66,'c':67,'d':68,'e':69,'f':70,'g':71,'h':72,'i':73,'j':74,'k':75,'l':76,'m':77,'n':78,'o':79,'p':80,'q':81,'r':82,'s':83,'t':84,'u':85,'v':86,'w':87,'x':88,'y':89,'z':90,'numpad_0':96,'numpad_1':97,'numpad_2':98,'numpad_3':99,'numpad_4':100,'numpad_5':101,'numpad_6':102,'numpad_7':103,'numpad_8':104,'numpad_9':105,'multiply_key':106,'add_key':107,'separator_key':108,'subtract_key':109,'decimal_key':110,'divide_key':111,'F1':112,'F2':113,'F3':114,'F4':115,'F5':116,'F6':117,'F7':118,'F8':119,'F9':120,'F10':121,'F11':122,'F12':123,'F13':124,'F14':125,'F15':126,'F16':127,'F17':128,'F18':129,'F19':130,'F20':131,'F21':132,'F22':133,'F23':134,'F24':135,'num_lock':144,'scroll_lock':145,'left_shift':160,'right_shift ':161,'left_control':162,'right_control':163,'left_menu':164,'right_menu':165,'browser_back':166,'browser_forward':167,'browser_refresh':168,'browser_stop':169,'browser_search':170,'browser_favorites':171,'browser_start_and_home':172,'volume_mute':173,'volume_Down':174,'volume_up':175,'next_track':176,'previous_track':177,'stop_media':178,'play/pause_media':179,'start_mail':180,'select_media':181,'start_application_1':182,'start_application_2':183,';':186,'+':187,',':188,'-':189,'.':190,'/':191,'`':192,'[':219,'\\':220,']':221,"'":222,'attn_key':246,'crsel_key':247,'exsel_key':248,'play_key':250,'zoom_key':251,'clear_key':254}
    def __init__(self):
        pass
c=C()
print(c.vk['mclick'])

Above example replicates this perfectly. Static dictionaries will break entirely when compiled with pyarmor 9.0.5 in any python version over 3.11. 3.11 is latest that function properly.

pyarmor gen --pack onefile test.py

@Apprisco Apprisco added the bug label Nov 14, 2024
@jondy
Copy link
Contributor

jondy commented Nov 14, 2024

As I have metioned, no pack, only obfuscate, does it work or not?

@Apprisco
Copy link
Author

I do not know how to test that. However, now you have a working, replicable, small example. So go try it.

@jondy
Copy link
Contributor

jondy commented Nov 14, 2024

As I have known, some Python rc version, for example, Python-3.12.0rc may not work.

So make sure you're use the latest patch for Python 3.11+

@Apprisco
Copy link
Author

Apprisco commented Nov 14, 2024

I am using latest python 3.13. And latest python 3.12, installed through conda. There are no rc versions involved

Can you replicate the above results or no?
Also noticing massive issues with Threading library in python >3.11, something to do with Thread.run and Thread.start does not support ContextManagerProtocol

@jondy
Copy link
Contributor

jondy commented Nov 15, 2024

Sorry, I can't reproduce it. What I test is

$ python3.12 -m pyarmor.cli gen tsrc/bugs/t1987.py 
$ python3.12 dist/t1987.py
4

It works fine

@fdteam-deanie
Copy link

class C:
    vk={'mclick':4,'backspace':8,'tab':9,'clear':12,'enter':13,'shift':16,'ctrl':17,'alt':18,'pause':19,'caps_lock':20,'esc':27,'spacebar':32,'page_up':33,'page_down':34,'end':35,'home':36,'left_arrow':37,'up_arrow':38,'right_arrow':39,'down_arrow':40,'select':41,'print':42,'execute':43,'print_screen':44,'ins':45,'del':46,'help':47,'0':48,'1':49,'2':50,'3':51,'4':52,'5':53,'6':54,'7':55,'8':56,'9':57,'a':65,'b':66,'c':67,'d':68,'e':69,'f':70,'g':71,'h':72,'i':73,'j':74,'k':75,'l':76,'m':77,'n':78,'o':79,'p':80,'q':81,'r':82,'s':83,'t':84,'u':85,'v':86,'w':87,'x':88,'y':89,'z':90,'numpad_0':96,'numpad_1':97,'numpad_2':98,'numpad_3':99,'numpad_4':100,'numpad_5':101,'numpad_6':102,'numpad_7':103,'numpad_8':104,'numpad_9':105,'multiply_key':106,'add_key':107,'separator_key':108,'subtract_key':109,'decimal_key':110,'divide_key':111,'F1':112,'F2':113,'F3':114,'F4':115,'F5':116,'F6':117,'F7':118,'F8':119,'F9':120,'F10':121,'F11':122,'F12':123,'F13':124,'F14':125,'F15':126,'F16':127,'F17':128,'F18':129,'F19':130,'F20':131,'F21':132,'F22':133,'F23':134,'F24':135,'num_lock':144,'scroll_lock':145,'left_shift':160,'right_shift ':161,'left_control':162,'right_control':163,'left_menu':164,'right_menu':165,'browser_back':166,'browser_forward':167,'browser_refresh':168,'browser_stop':169,'browser_search':170,'browser_favorites':171,'browser_start_and_home':172,'volume_mute':173,'volume_Down':174,'volume_up':175,'next_track':176,'previous_track':177,'stop_media':178,'play/pause_media':179,'start_mail':180,'select_media':181,'start_application_1':182,'start_application_2':183,';':186,'+':187,',':188,'-':189,'.':190,'/':191,'`':192,'[':219,'\\':220,']':221,"'":222,'attn_key':246,'crsel_key':247,'exsel_key':248,'play_key':250,'zoom_key':251,'clear_key':254}
    def __init__(self):
        pass
c=C()
print(c.vk['mclick'])

Above example replicates this perfectly. Static dictionaries will break entirely when compiled with pyarmor 9.0.5 in any python version over 3.11. 3.11 is latest that function properly.

pyarmor gen --pack onefile test.py

You seem to be rude to the author and your Github issue is very uninformative and unprofessional.
Here is my test for you:

  • Python 3.12.7.
  • Pyarmor Group license the latest (9.0.5).
  • Run command pyarmor gen --pack onefile main.py as your example.

None of problem like yours.

image

@Apprisco
Copy link
Author

Apprisco commented Nov 15, 2024

@fdteam-deanie
I'm rude to the repo author? He's been closing my issues w/o even trying to replicate the issues.

Fresh conda environment, python 3.12.7. Replicated issue inconsistently, happens once every ~4 compiles.
Have you tried python 3.13.0 though? Happens every time.
image
My pro license is from 8.5, but seems to work on 9.0.5.

image

@Apprisco
Copy link
Author

Sorry, I can't reproduce it. What I test is

$ python3.12 -m pyarmor.cli gen tsrc/bugs/t1987.py 
$ python3.12 dist/t1987.py
4

It works fine

Can you try python 3.13? On 3.12 it's very unreliable to replicate, which is interesting.

@Apprisco Apprisco changed the title [BUG] static dictionaries will cause Int/Str not callable error once compiled in Python>3.11 [BUG] static dictionaries will cause Int/Str not callable error once compiled in Python>3.12 Nov 15, 2024
@jondy
Copy link
Contributor

jondy commented Nov 16, 2024

Reproduced in Python 3.13, I'll check it

@jondy
Copy link
Contributor

jondy commented Nov 16, 2024

Found problem, it will be fixed in next released.

Before released, the pre-release version is available here

https://pyarmor.dashingsoft.com/downloads/temp/pyarmor-9.0.6.zip

@Apprisco
Copy link
Author

Found problem, it will be fixed in next released.

Before released, the pre-release version is available here

https://pyarmor.dashingsoft.com/downloads/temp/pyarmor-9.0.6.zip

Thank you. I'll see if I can get that byte slicing memory leak to be replicable as well.

Something is also preventing my script from launching post pyarmor in python 3.12, but not in 3.13. Not a huge issue.
Threading library in 3.13 support is very spotty, getting the weirdest errors ever.

image
Every thread made is causing the above, but also not when it's created normally?? Also, daemon threads seem to halt the whole process immediately, tho that's a py3.13 problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants