SiteSupport/gevent — pull request #251 by jgehrcke (2013-02-14 15:57:21+00:00)
Title: Fix segfault upon calling __repr__() of destroyed loop.

Currently,
```python
import gevent
h = gevent.get_hub()
loop = h.loop
print loop
h.destroy(destroy_loop=True)
print loop
```
makes the program crash with segmentation fault upon the last `print loop` statement. This is because the `__repr__()` method of a destroyed loop makes libev API calls with a previously invalidated event loop pointer.

When the loop object is still bound to a name, then `_ptr == NULL` means that the loop has been destroyed (`_ptr` is only set to `NULL` upon destruction and deallocation). This relation is used by the patch. It makes the above code print
```

```

I see that the repro code is quite an edge case. Nevertheless, I hit this issue when playing with loop creation/destruction and printing debug information. When a Python object is in the namespace, the program definitely should not crash when trying to `print` this object.