Fix for memory leak and doctest#96
Conversation
|
Uhm, I'm quite surprised of that usa^H^H^Habuse of the |
|
Unless I'm missing the obvious, I think a better way would be using |
|
There's no use case for that kind of abuse. This was my first attempt at Python in C-land (c++ actually) so I'm still learning. Reading the docs I found that was recommended, as you never can tell how users will use your code, and you should strive to not break in all cases. I agree initialization of the RawJSON class is better done in the I updated the PR with the switch |
| static int | ||
| RawJSON_init(RawJSON* self, PyObject* args, PyObject* kwds) | ||
| static PyObject * | ||
| RawJSON_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
There was a problem hiding this comment.
Please follow overall stylistic convention, using PyObject* foo instead of PyObject *foo: although it's not my preferred style, but I tried to adhere to the one originally used by Ken
| self->value = value; | ||
| Py_XDECREF(tmp); | ||
| } | ||
| ((RawJSON*)self)->value = value; |
|
Thanks, sorry for being so picky ;-) |
|
@lelit np! I understand :) Thanks for maintaining the project! |
|
Thanks Silvio, I merged this and released v0.5.0! |
The
__init__constructor of theRawJSONclass can be invoked multiple times (silly, but possible).So the code that takes care of the reference count of the previous
valueprobably needs to stay.I changed the way doctests are run in travis, so that the make the build fail. This uncovered a problem in a doctest: the timezone of the test environment was relevant, so tests were passing on my machine but failing on Travis. I added the
DM_NAIVE_IS_UTCflag to fix them.I added tests with the only python-debug version I could find on travis-ci: 3.4.
I'm not sure how these changes interact with the distribution build though.