_inplacevar_ error when doing in-place operation (Python)

As the title says, doing in-place operation (I did += and -= ) will result in “NameError: name ‘inplacevar’ is not defined”. You could try in system console, using Python language. Doing it as x = x + 1 or x = x - 1 seems to work though, but why the in-place operation results in error?

x = 1
x += 1

will result in:

Traceback (most recent call last):
  File "apps/frappe/frappe/desk/doctype/system_console/system_console.py", line 17, in run
  File "apps/frappe/frappe/utils/safe_exec.py", line 72, in safe_exec
    exec(compile_restricted(script), exec_globals, _locals)  # pylint: disable=exec-used
  File "<unknown>", line 2, in <module>
NameError: name '_inplacevar_' is not defined

While this:

x = 1
x = x + 1

result in



Hello @scratching_head ,

Frappe has imposed limitations on specific syntax elements, such as the addition assignment operator. These restrictions apply within the System Console and Server Scripts. However, when developing custom applications in Visual Studio Code, the usage of such syntax is permitted.

Certain operations are restricted in safe_exec.