Repository: alan-turing-institute/CleverCSV (language: python)

Issue:
Problem with names defined in cparser and cabstraction modules
Hi,

I'm currently working with a dynamic code analysis tool and I've noticed that it doesn't work very well with CleverCSV.

The problem seems to come from the fully qualified names defined in the cparser and cabstraction modules.

When I run the following code:

```python
import clevercsv

print(clevercsv.cabstraction.__name__)
print(clevercsv.cparser.__name__)
print(clevercsv.cparser.Error.__module__)
print(clevercsv.cparser.Parser.__module__)
```

I got the following output:

```
ccsv.cabstraction
ccsv.cparser
cparser
ccsv.cparser
```

But I expected to get something like that:

```
clevercsv.cabstraction
clevercsv.cparser
clevercsv.cparser
clevercsv.cparser
```

I hope this will help you find the problem.
Have a nice day!
Problem with names defined in cparser and cabstraction modules
Hi,

I'm currently working with a dynamic code analysis tool and I've noticed that it doesn't work very well with CleverCSV.

The problem seems to come from the fully qualified names defined in the cparser and cabstraction modules.

When I run the following code:

```python
import clevercsv

print(clevercsv.cabstraction.__name__)
print(clevercsv.cparser.__name__)
print(clevercsv.cparser.Error.__module__)
print(clevercsv.cparser.Parser.__module__)
```

I got the following output:

```
ccsv.cabstraction
ccsv.cparser
cparser
ccsv.cparser
```

But I expected to get something like that:

```
clevercsv.cabstraction
clevercsv.cparser
clevercsv.cparser
clevercsv.cparser
```

I hope this will help you find the problem.
Have a nice day!


Discussion / hints:

Fix patch:
diff --git a/src/abstraction.c b/src/abstraction.c
index 1fee2fd4..fc5111cc 100644
--- a/src/abstraction.c
+++ b/src/abstraction.c
@@ -290,7 +290,7 @@ static struct PyMethodDef cabstraction_methods[] = {
 
 static struct PyModuleDef moduledef = {
 	PyModuleDef_HEAD_INIT,
-	"ccsv.cabstraction",
+	"clevercsv.cabstraction",
 	cabstraction_module_doc,
 	-1,
 	cabstraction_methods,
diff --git a/src/cparser.c b/src/cparser.c
index 6b31279e..b9786173 100644
--- a/src/cparser.c
+++ b/src/cparser.c
@@ -698,7 +698,7 @@ static struct PyMethodDef cparser_methods[] = {
 
 static struct PyModuleDef _cparsermodule = {
 	PyModuleDef_HEAD_INIT,
-	"ccsv.cparser",
+	"clevercsv.cparser",
 	cparser_module_doc,
 	sizeof(_cparserstate),
 	cparser_methods,
@@ -727,7 +727,7 @@ PyMODINIT_FUNC PyInit_cparser(void)
 
 
 	/* Add the CSV exception object to the module. */
-	_cparserstate(module)->error_obj = PyErr_NewException("cparser.Error", NULL, NULL);
+	_cparserstate(module)->error_obj = PyErr_NewException("clevercsv.cparser.Error", NULL, NULL);
 	if (_cparserstate(module)->error_obj == NULL)
 		return NULL;
 	Py_INCREF(_cparserstate(module)->error_obj);


Test patch:
diff --git a/tests/test_unit/test_c_file_naming.py b/tests/test_unit/test_c_file_naming.py
new file mode 100644
index 00000000..8e6620b4
--- /dev/null
+++ b/tests/test_unit/test_c_file_naming.py
@@ -0,0 +1,23 @@
+import unittest
+
+import clevercsv
+
+
+class CNamingTestCase(unittest.TestCase):
+    def test_name_cabstraction_module(self) -> None:
+        self.assertEqual(
+            clevercsv.cabstraction.__name__, "clevercsv.cabstraction"
+        )
+
+    def test_name_cparser_module(self) -> None:
+        self.assertEqual(clevercsv.cparser.__name__, "clevercsv.cparser")
+
+    def test_name_cparser_error(self) -> None:
+        self.assertEqual(
+            clevercsv.cparser.Error.__module__, "clevercsv.cparser"
+        )
+
+    def test_name_cparser_parser(self) -> None:
+        self.assertEqual(
+            clevercsv.cparser.Parser.__module__, "clevercsv.cparser"
+        )