scipy/scipy — pull request #3880 by blink1073 (2014-08-17 02:30:51+00:00)
Title: Fix KeyboardInterrupt Behavior on Windows

The following code results in an error on Windows due to the Fortran imports in `scipy`:

```python
import scipy.stats
import time

print('sleeping')
try:
time.sleep(100)
except KeyboardInterrupt:
print('Interrupted')
```

```
sleeping
forrtl: error (200): program aborting due to control-C event
Image PC Routine Line Source

kernel32.dll 00000000775E4AE3 Unknown Unknown Unknown
kernel32.dll 00000000775A59ED Unknown Unknown Unknown
ntdll.dll 00000000777DC541 Unknown Unknown Unknown
```

The same problem occurs with `scipy.io`, and likely any of the subpackages that use Fortran code.
This patch fixes this and is based on this [stackoverflow](http://stackoverflow.com/questions/15457786/ctrl-c-crashes-python-after-importing-scipy-stats) question, but without requiring the `win32api` library.

Notes:
- This cannot be run within a function, it has to be run at the module level.
- This has to be done prior to importing `numpy` or `time` (hence the use of `imp`).
- Tested the behavior on Windows 7 with Anaconda builds of Scipy 0.14.0 for Python 2.7 and Python 3.3.