summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-11-24 12:22:17 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-11-24 12:22:17 -0500
commitaab439abc73976b077f1058f488be3e914b5861f (patch)
treeb47199cd4104154485f479836cad5d1978898ff2
parentc848624f9db325213ddf2fde9819946f9eb235cd (diff)
parentbb6ed3e111362b4656b4bc6a9f189882170f7770 (diff)
downloadsqlalchemy-aab439abc73976b077f1058f488be3e914b5861f.tar.gz
merge tip
-rw-r--r--lib/sqlalchemy/cextension/processors.c11
-rw-r--r--test/aaa_profiling/test_memusage.py17
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/sqlalchemy/cextension/processors.c b/lib/sqlalchemy/cextension/processors.c
index 327462fa8..193fb19f3 100644
--- a/lib/sqlalchemy/cextension/processors.c
+++ b/lib/sqlalchemy/cextension/processors.c
@@ -289,6 +289,7 @@ DecimalResultProcessor_process(DecimalResultProcessor *self, PyObject *value)
return NULL;
str = PyString_Format(self->format, args);
+ Py_DECREF(args);
if (str == NULL)
return NULL;
@@ -300,6 +301,14 @@ DecimalResultProcessor_process(DecimalResultProcessor *self, PyObject *value)
}
}
+static void
+DecimalResultProcessor_dealloc(DecimalResultProcessor *self)
+{
+ Py_XDECREF(self->type);
+ Py_XDECREF(self->format);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
static PyMethodDef DecimalResultProcessor_methods[] = {
{"process", (PyCFunction)DecimalResultProcessor_process, METH_O,
"The value processor itself."},
@@ -312,7 +321,7 @@ static PyTypeObject DecimalResultProcessorType = {
"sqlalchemy.DecimalResultProcessor", /* tp_name */
sizeof(DecimalResultProcessor), /* tp_basicsize */
0, /* tp_itemsize */
- 0, /* tp_dealloc */
+ (destructor)DecimalResultProcessor_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py
index 5fa40a997..dbf6e8ce1 100644
--- a/test/aaa_profiling/test_memusage.py
+++ b/test/aaa_profiling/test_memusage.py
@@ -11,7 +11,9 @@ from sqlalchemy import MetaData, Integer, String, ForeignKey, \
from sqlalchemy.test.schema import Table, Column
import sqlalchemy as sa
from sqlalchemy.sql import column
+from sqlalchemy.processors import to_decimal_processor_factory
from sqlalchemy.test.util import gc_collect
+from decimal import Decimal as _python_Decimal
import gc
import weakref
from test.orm import _base
@@ -565,4 +567,17 @@ class MemUsageTest(EnsureZeroed):
dialect = SQLiteDialect()
cast.compile(dialect=dialect)
go()
-
+
+ @testing.requires.cextensions
+ def test_DecimalResultProcessor_init(self):
+ @profile_memory
+ def go():
+ to_decimal_processor_factory({}, 10)
+ go()
+
+ @testing.requires.cextensions
+ def test_DecimalResultProcessor_process(self):
+ @profile_memory
+ def go():
+ to_decimal_processor_factory(_python_Decimal, 10)(1.2)
+ go()