4
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.

markgz
  • 6,054
  • 1
  • 19
  • 41
sgarza62
  • 5,998
  • 8
  • 49
  • 69
  • This seems to be OS (or build) specific. Just for reference: it works fine on python2.7 [GCC 4.8.1] on linux2. – Hyperboreus Apr 10 '14 at 18:31
  • 3
    Found it: http://stackoverflow.com/questions/19531969/segmentation-fault-11-in-os-x – Hyperboreus Apr 10 '14 at 18:32
  • @Hyperboreus Ah, you're right. I hadn't realized it was invariably seg faulting on the second command. Thanks for catching that! – sgarza62 Apr 10 '14 at 18:34

1 Answers1

1

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.

Community
  • 1
  • 1
sgarza62
  • 5,998
  • 8
  • 49
  • 69