wepay/Python-SDK — pull request #13 by kevinjqiu (2014-04-21 15:56:53+00:00)
Title: Fix WePayError.

Python's base class `Exception` takes only a single parameter as
"message":

```
>>> Exception("foo").message
'foo'
```

but if you pass more arguments to the `Exception` constructor, it
doesn't populate the `message` field:

```
>>> Exception("foo", "bar", "quux").message
''
```

Here's the corresponding Python source code:

```c
static int
BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
{
if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
return -1;

Py_DECREF(self->args);
self->args = args;
Py_INCREF(self->args);

if (PyTuple_GET_SIZE(self->args) == 1) {
Py_CLEAR(self->message);
self->message = PyTuple_GET_ITEM(self->args, 0);
Py_INCREF(self->message);
}
return 0;
}
```
You can see it sets `self->message` to `args[0]` if the size of the
tuple is 1. Otherwise, it skips setting `self->message`.