Comparisons and sorting of a numeric class....

Chris Angelico rosuav at gmail.com
Tue Jan 13 01:13:52 EST 2015


On Tue, Jan 13, 2015 at 4:32 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Crashing the interpreter from
> pure Python code is *absolutely not allowed*, so anything which would
> allow that is forbidden.

Except when you willingly shoot yourself in the foot.

rosuav at sikorsky:~$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> def f(): sys.setrecursionlimit(sys.getrecursionlimit()+1) or f()
...
>>> f()
Segmentation fault
rosuav at sikorsky:~$ python3
Python 3.5.0a0 (default:1c51f1650c42+, Dec 29 2014, 02:29:06)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> def f(): sys.setrecursionlimit(sys.getrecursionlimit()+1) or f()
...
>>> f()
Segmentation fault

But otherwise, yes. You shouldn't be able to segfault Python with Python code.

ChrisA



More information about the Python-list mailing list