ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

Transforming types of loop condition in 'for' crashes ironpython

Open xiaxinmeng opened this issue 3 years ago • 2 comments

Using int(), str(), to transform the type of loop condition causes crashes in ironpython. See the following test.py.

test.py

for int(i) in range(10):
	print(i)

Error message:

>>'ironpython/ironpython3/bin/Debug/net6.0/ipy' test.py
.....
ting/Shell/CommandLine.cs:line 100
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.RunCommandLine() in /home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/Src/DLR/Src/Microsoft.Dynamic/Hosting/Shell/ConsoleHost.cs:line 386
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.ExecuteInternal() in /home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/Src/DLR/Src/Microsoft.Dynamic/Hosting/Shell/ConsoleHost.cs:line 321
   at PythonConsoleHost.ExecuteInternal() in /home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/Src/IronPythonConsole/Console.cs:line 165
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.Execute() in /home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/Src/DLR/Src/Microsoft.Dynamic/Hosting/Shell/ConsoleHost.cs:line 299
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.Run(String[] args) in /home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/Src/DLR/Src/Microsoft.Dynamic/Hosting/Shell/ConsoleHost.cs:line 197
   at PythonConsoleHost.Main(String[] args) in /home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/ironpython/ironpython3/Src/IronPythonConsole/Console.cs:line 199
Aborted (core dumped)

System info: ironpython3-debug(main branch):IronPython 3.4.0b1 DEBUG (3.4.0.0010)[.NETCoreApp,Version=v6.0 on .NET 6.0.11 (64-bit)] on linux operating system: Ubuntu 18.04.6 LTS

xiaxinmeng avatar Dec 10 '22 14:12 xiaxinmeng

Thanks! Crashes in debug mode due to an assertion error. In release mode we get a SystemError:

SystemError: Operation is not valid due to the current state of the object.

instead of the expected SyntaxError:

SyntaxError: can't assign to function call

slozier avatar Dec 10 '22 19:12 slozier

Not just transforming types, the following raises an assertion error as well:

for 1 in range(10):
    pass

slozier avatar Dec 13 '22 01:12 slozier