summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-05-01 19:26:01 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-05-02 07:38:20 -0400
commit540da6d02dc6f5f1e81ccb3dcb73257f47eb8f90 (patch)
tree5086249db4fcd222d3245f444e0c0a47c6dffcc6
parentc6ba56c68b2a3850f530cc1fdbf9856a90559a1f (diff)
downloadpython-coveragepy-git-540da6d02dc6f5f1e81ccb3dcb73257f47eb8f90.tar.gz
refactor: remove unneeded Py2 C code
-rw-r--r--coverage/ctracer/module.c39
-rw-r--r--coverage/ctracer/util.h20
2 files changed, 0 insertions, 59 deletions
diff --git a/coverage/ctracer/module.c b/coverage/ctracer/module.c
index f308902b..d564a812 100644
--- a/coverage/ctracer/module.c
+++ b/coverage/ctracer/module.c
@@ -9,8 +9,6 @@
#define MODULE_DOC PyDoc_STR("Fast coverage tracer.")
-#if PY_MAJOR_VERSION >= 3
-
static PyModuleDef
moduledef = {
PyModuleDef_HEAD_INIT,
@@ -69,40 +67,3 @@ PyInit_tracer(void)
return mod;
}
-
-#else
-
-void
-inittracer(void)
-{
- PyObject * mod;
-
- mod = Py_InitModule3("coverage.tracer", NULL, MODULE_DOC);
- if (mod == NULL) {
- return;
- }
-
- if (CTracer_intern_strings() < 0) {
- return;
- }
-
- /* Initialize CTracer */
- CTracerType.tp_new = PyType_GenericNew;
- if (PyType_Ready(&CTracerType) < 0) {
- return;
- }
-
- Py_INCREF(&CTracerType);
- PyModule_AddObject(mod, "CTracer", (PyObject *)&CTracerType);
-
- /* Initialize CFileDisposition */
- CFileDispositionType.tp_new = PyType_GenericNew;
- if (PyType_Ready(&CFileDispositionType) < 0) {
- return;
- }
-
- Py_INCREF(&CFileDispositionType);
- PyModule_AddObject(mod, "CFileDisposition", (PyObject *)&CFileDispositionType);
-}
-
-#endif /* Py3k */
diff --git a/coverage/ctracer/util.h b/coverage/ctracer/util.h
index 420b1cbb..adb36d5d 100644
--- a/coverage/ctracer/util.h
+++ b/coverage/ctracer/util.h
@@ -12,10 +12,6 @@
#undef COLLECT_STATS /* Collect counters: stats are printed when tracer is stopped. */
#undef DO_NOTHING /* Define this to make the tracer do nothing. */
-/* Py 2.x and 3.x compatibility */
-
-#if PY_MAJOR_VERSION >= 3
-
#define MyText_Type PyUnicode_Type
#define MyText_AS_BYTES(o) PyUnicode_AsASCIIString(o)
#define MyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
@@ -28,22 +24,6 @@
#define MyType_HEAD_INIT PyVarObject_HEAD_INIT(NULL, 0)
-#else
-
-#define MyText_Type PyString_Type
-#define MyText_AS_BYTES(o) (Py_INCREF(o), o)
-#define MyBytes_GET_SIZE(o) PyString_GET_SIZE(o)
-#define MyBytes_AS_STRING(o) PyString_AS_STRING(o)
-#define MyText_AsString(o) PyString_AsString(o)
-#define MyText_FromFormat PyUnicode_FromFormat
-#define MyInt_FromInt(i) PyInt_FromLong((long)i)
-#define MyInt_AsInt(o) (int)PyInt_AsLong(o)
-#define MyText_InternFromString(s) PyString_InternFromString(s)
-
-#define MyType_HEAD_INIT PyObject_HEAD_INIT(NULL) 0,
-
-#endif /* Py3k */
-
// The f_lasti field changed meaning in 3.10.0a7. It had been bytes, but
// now is instructions, so we need to adjust it to use it as a byte index.
#if PY_VERSION_HEX >= 0x030A00A7