Comparisons and sorting of a numeric class....

Terry Reedy tjreedy at udel.edu
Tue Jan 13 11:49:22 CET 2015


On 1/13/2015 1:13 AM, Chris Angelico wrote:
> 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.

I would have expected an out-of-memory error.  If there is not already a 
crash issue on the tracker for this, you could add one.


-- 
Terry Jan Reedy




More information about the Python-list mailing list