Skip to content

Commit

Permalink
fix: remove 'simple_new' fossil (#208)
Browse files Browse the repository at this point in the history
Closees #206.
  • Loading branch information
tseaver authored Sep 4, 2024
1 parent 12fd1cc commit b70746b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
22 changes: 0 additions & 22 deletions src/persistent/cPersistence.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ struct ccobject_head_struct
#include <stdint.h>
#include <inttypes.h>

/* These objects are initialized when the module is loaded */
static PyObject *py_simple_new;

/* Strings initialized by init_strings() below. */
static PyObject *py_keys, *py_setstate, *py___dict__, *py_timeTime;
static PyObject *py__p_changed, *py__p_deactivate;
Expand Down Expand Up @@ -1624,23 +1621,8 @@ Per_setstate(cPersistentObject *self)
return 0;
}

static PyObject *
simple_new(PyObject *self, PyObject *type_object)
{
if (!PyType_Check(type_object))
{
PyErr_SetString(PyExc_TypeError,
"simple_new argument must be a type object.");
return NULL;
}
return PyType_GenericNew((PyTypeObject *)type_object, NULL, NULL);
}

static PyMethodDef cPersistence_methods[] =
{
{"simple_new", simple_new, METH_O,
"Create an object by simply calling a class's __new__ method without "
"arguments."},
{NULL, NULL}
};

Expand Down Expand Up @@ -1713,10 +1695,6 @@ module_init(void)
cPersistent_STICKY_STATE) < 0)
return NULL;

py_simple_new = PyObject_GetAttrString(module, "simple_new");
if (!py_simple_new)
return NULL;

copy_reg = PyImport_ImportModule("copyreg");
if (!copy_reg)
return NULL;
Expand Down
17 changes: 0 additions & 17 deletions src/persistent/tests/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2204,22 +2204,5 @@ def _makeCache(self, jar):
return PickleCache(jar)


@skipIfNoCExtension
class Test_simple_new(unittest.TestCase):

def _callFUT(self, x):
from persistent._compat import _c_optimizations_available as get_c
simple_new = get_c()['persistent.persistence'].simple_new
return simple_new(x)

def test_w_non_type(self):
self.assertRaises(TypeError, self._callFUT, '')

def test_w_type(self):
TO_CREATE = [type, list, tuple, object, dict]
for typ in TO_CREATE:
self.assertIsInstance(self._callFUT(typ), typ)


def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)

0 comments on commit b70746b

Please sign in to comment.