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

Using '+=', '-=' etc. operators inside a class's function throws SyntaxError. #105

Open
NickGeramanis opened this issue Apr 18, 2020 · 1 comment
Labels

Comments

@NickGeramanis
Copy link

Creating an instance object of this class inside bot.py

class Test:
    def __init__(self, value):
        self.x = 3
        self.x += value

produces the following error

Traceback (most recent call last):
  File "/home/nickger/Dev/Battlehack/venv/src/run.py", line 98, in <module>
    code_container1 = CodeContainer.from_directory(args.player[0])
  File "/home/nickger/Dev/Battlehack/venv/lib/python3.6/site-packages/battlehack20/engine/container/code_container.py", line 34, in from_directory
    return cls.from_directory_dict(code)
  File "/home/nickger/Dev/Battlehack/venv/lib/python3.6/site-packages/battlehack20/engine/container/code_container.py", line 20, in from_directory_dict
    compiled = compile_restricted(cls.preprocess(dic[filename]), filename, 'exec')
  File "/home/nickger/Dev/Battlehack/venv/lib/python3.6/site-packages/RestrictedPython/compile.py", line 205, in compile_restricted
    raise SyntaxError(result.errors)
SyntaxError: ('Line 4: Augmented assignment of attributes is not allowed.',)
@NickGeramanis
Copy link
Author

This error is thrown even if you dont call the constructor.
In other words if the above class exists in a different file (or in the bot.py) inside the folder, the above error occurs.

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

2 participants