getsentry/raven-python — pull request #398 by bgilbert (2013-12-13 01:48:22+00:00)
Title: Add Context.__len__() method

`Mapping.__len__()` is abstract and `Context` wasn't implementing it. Normally, `Mapping`'s metaclass would therefore prevent `Context` from being instantiated, but this check is not performed due to `Context`'s multiple inheritance:

>>> from raven.context import Context
>>> Context()

However, when gunicorn is used with gevent workers, gevent supplies its own implementation of `threading.local` which does run the checks:

>>> import gevent.monkey
>>> gevent.monkey.patch_all()
>>> from raven.context import Context
>>> Context()
Traceback (most recent call last):
File "", line 1, in
File "[...]/gevent/local.py", line 141, in __new__
self = object.__new__(cls)
TypeError: Can't instantiate abstract class Context with abstract methods __len__

Fix by implementing the method.