Skip to content

Commit 1285eb1

Browse files
committed
Remove clear
1 parent 9b633ca commit 1285eb1

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/main.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ static PyObject* PyXmlSec_PyInit(PyObject *self) {
114114
static char PyXmlSec_PyShutdown__doc__[] = \
115115
"shutdown() -> None\n"
116116
"Shutdowns the library and cleanup any leftover resources.\n\n"
117-
"This is called automatically upon interpreter termination and\n"
118-
"should not need to be called explicitly.";
117+
"This is not called automatically upon interpreter termination because\n"
118+
"xmlsec-owned objects may still be finalized during Python shutdown.";
119119
static PyObject* PyXmlSec_PyShutdown(PyObject* self) {
120120
PyXmlSec_Free(free_mode);
121121
Py_RETURN_NONE;
@@ -488,11 +488,6 @@ int PyXmlSec_EncModule_Init(PyObject* package);
488488
// templates management
489489
int PyXmlSec_TemplateModule_Init(PyObject* package);
490490

491-
static int PyXmlSec_PyClear(PyObject *self) {
492-
PyXmlSec_Free(free_mode);
493-
return 0;
494-
}
495-
496491
static PyModuleDef PyXmlSecModule = {
497492
PyModuleDef_HEAD_INIT,
498493
STRINGIFY(MODULE_NAME), /* name of module */
@@ -502,7 +497,7 @@ static PyModuleDef PyXmlSecModule = {
502497
PyXmlSec_MainMethods, /* m_methods */
503498
NULL, /* m_slots */
504499
NULL, /* m_traverse */
505-
PyXmlSec_PyClear, /* m_clear */
500+
NULL, /* m_clear */
506501
NULL, /* m_free */
507502
};
508503

tests/test_xmlsec.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import subprocess
2+
import sys
3+
14
import xmlsec
25
from tests import base
36

@@ -11,3 +14,15 @@ def test_reinitialize_module(self):
1114
"""
1215
xmlsec.shutdown()
1316
xmlsec.init()
17+
18+
def test_interpreter_exit_with_live_xmlsec_objects(self):
19+
key_path = self.path('rsakey.pem')
20+
script = f"""
21+
import xmlsec
22+
23+
key = xmlsec.Key.from_file({key_path!r}, format=xmlsec.constants.KeyDataFormatPem)
24+
ctx = xmlsec.SignatureContext()
25+
ctx.key = key
26+
"""
27+
proc = subprocess.run([sys.executable, '-c', script], capture_output=True, text=True)
28+
self.assertEqual(proc.returncode, 0, proc.stderr)

0 commit comments

Comments
 (0)