Вопрос

MacBook-Air:~ sgarza62$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 % 10
1
>>> 10 % 1
Segmentation fault: 11

Also happens with modulo operations such as 1 % 1 and 2 % 2.

Running Mac OS 10.9.2 on this machine.

Это было полезно?

Решение

This has nothing to do with the modulo operation. The interactive interpreter will crash on every 2nd command invoked.

The OS 10.9 (Mavericks) upgrade caused instability in some Python releases. To fix this specific issue, download and run the patch through the Terminal:

>>> curl -O http://bugs.python.org/file32324/patch_readline_issue_18458.sh
>>> openssl sha1 patch_readline_issue_18458.sh
>>> sh ./patch_readline_issue_18458.sh

Newer Python releases have fixed the problems introduced with Mavericks. Better to install the latest version at https://www.python.org/downloads/

Thanks to Hyperboreus for finding the solution in the question comments.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top