martinkou/bson — pull request #24 by andreas (2014-06-12 13:10:51+00:00)
Title: Add optional on_unknown handler to bson.dumps

This PR adds an optional `on_unknown`-argument to `bson.dumps`, mirroring the functionality from `jsonlib`: https://pypi.python.org/pypi/jsonlib/1.3.10#serializing-other-types . In short, it allows converting unknown values to convertible values when dumping an object:

```python
bson.dumps({"val": Decimal("123.45")}, on_unknown=float)
```

This will dump the Decimal as float instead of `None` as is currently the case. If a `on_unknown`-argument is not provided and an unknown value encountered, a `UnknownSerializer`-exception is raised.