Files
pytorch/torch/csrc/dl.c
David Reiss 6d642a6f6c Remove (most) Python 2 support from C++ code (#35614)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35614

Python 2 has reached end-of-life and is no longer supported by PyTorch.
Now we can clean up a lot of cruft that we put in place to support it.
These changes were all done manually, and I skipped anything that seemed
like it would take more than a few seconds, so I think it makes sense to
review it manually as well.

Test Plan: CI

Differential Revision: D20842876

Pulled By: dreiss

fbshipit-source-id: 18abf0d324ed2185ec6d27c864e935d856dcc6ad
2020-05-14 15:01:49 -07:00

32 lines
696 B
C

#include <Python.h>
#include <dlfcn.h>
PyObject* module;
static PyMethodDef TorchDlMethods[] = {
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef torchdlmodule = {
PyModuleDef_HEAD_INIT,
"torch._dl",
NULL,
-1,
TorchDlMethods
};
PyMODINIT_FUNC PyInit__dl(void)
{
#define ASSERT_TRUE(cmd) if (!(cmd)) return NULL
ASSERT_TRUE(module = PyModule_Create(&torchdlmodule));
ASSERT_TRUE(PyModule_AddIntConstant(module, "RTLD_GLOBAL", (int64_t) RTLD_GLOBAL) == 0);
ASSERT_TRUE(PyModule_AddIntConstant(module, "RTLD_NOW", (int64_t) RTLD_NOW) == 0);
ASSERT_TRUE(PyModule_AddIntConstant(module, "RTLD_LAZY", (int64_t) RTLD_LAZY) == 0);
return module;
#undef ASSERT_TRUE
}