[issue37418] Code execution without calling it

2019-06-26 Thread SilentGhost
SilentGhost added the comment: The whole file is executed on import, you might as well have taken the "evil" code and placed in the global scope and not in the function. If you want to learn how to use decorators, again I suggest following a tutorial, SO or python-help. This is not a securit

[issue37418] Code execution without calling it

2019-06-26 Thread Paul Ganssle
Change by Paul Ganssle : -- nosy: -p-ganssle ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue37418] Code execution without calling it

2019-06-26 Thread Paul Ganssle
Paul Ganssle added the comment: > why the code is executed? > I could do a library or a package and include evil code instead of a > print... The code is executed because the decorator syntax @decorator def f(): ... Is equivalent to def f(): ... f = decorator(

[issue37418] Code execution without calling it

2019-06-26 Thread Emilio López Arias
Emilio López Arias added the comment: why the code is executed? I could do a library or a package and include evil code instead of a print... El mié., 26 jun. 2019 a las 21:05, SilentGhost () escribió: > > SilentGhost added the comment: > > It seems you're misunderstanding mechanics of decora

[issue37418] Code execution without calling it

2019-06-26 Thread SilentGhost
SilentGhost added the comment: It seems you're misunderstanding mechanics of decorators. Decorator is called when @decorator statement is executed and in that function *you* are calling the wrapped function. There are tutorials available on how to use this feature, I'd suggest you try them.

[issue37418] Code execution without calling it

2019-06-26 Thread Emilio López Arias
New submission from Emilio López Arias : Create a new python file: example.py def my_decorator(f): print("before") f() print("after") @my_decorator def my_function(): print("hello world")