For anyone who receives
Traceback (most recent call last): SystemError: Operation is not valid due to the current state of the object.
immediately upon running a Python script, check whether the code contains an invalid for loop such as
def test(): for 1 in 0,1,2: pass
When executed at Online Python Compiler v2.7.13 , the same code returns:
File "main.py", line 2 for 1 in 0,1,2: SyntaxError: can't assign to literal