]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Set type names earlier in posixmodule.c (#140168)
authorVictor Stinner <vstinner@python.org>
Thu, 16 Oct 2025 10:54:57 +0000 (12:54 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Oct 2025 10:54:57 +0000 (12:54 +0200)
Lib/test/test_os/test_os.py
Modules/posixmodule.c

index dd6f89e81aac87b593d6102ab52baf63bb9c2120..9bb4cb7e526b4fd47819fbb8838abf6eef0ee5e2 100644 (file)
@@ -164,6 +164,20 @@ class MiscTests(unittest.TestCase):
         self.assertIsInstance(cwd, bytes)
         self.assertEqual(os.fsdecode(cwd), os.getcwd())
 
+    def test_type_fqdn(self):
+        def fqdn(obj):
+            return (obj.__module__, obj.__qualname__)
+
+        native = os.name
+        self.assertEqual(fqdn(os.stat_result), ("os", "stat_result"))
+        self.assertEqual(fqdn(os.times_result), (native, "times_result"))
+        if hasattr(os, "statvfs_result"):
+            self.assertEqual(fqdn(os.statvfs_result), ("os", "statvfs_result"))
+        if hasattr(os, "sched_param"):
+            self.assertEqual(fqdn(os.sched_param), (native, "sched_param"))
+        if hasattr(os, "waitid_result"):
+            self.assertEqual(fqdn(os.waitid_result), (native, "waitid_result"))
+
 
 # Tests creating TESTFN
 class FileTests(unittest.TestCase):
index e2b7146237feb68a2507f15495438094ae4e94b1..5c1c508578a31e5301eaf703b445ee3bab40eaef 100644 (file)
@@ -2471,7 +2471,7 @@ static PyStructSequence_Field stat_result_fields[] = {
 #endif
 
 static PyStructSequence_Desc stat_result_desc = {
-    "stat_result", /* name */
+    "os.stat_result", /* name; see issue gh-63408 */
     stat_result__doc__, /* doc */
     stat_result_fields,
     10
@@ -2501,7 +2501,7 @@ static PyStructSequence_Field statvfs_result_fields[] = {
 };
 
 static PyStructSequence_Desc statvfs_result_desc = {
-    "statvfs_result", /* name */
+    "os.statvfs_result", /* name; see issue gh-63408 */
     statvfs_result__doc__, /* doc */
     statvfs_result_fields,
     10
@@ -2526,7 +2526,7 @@ static PyStructSequence_Field waitid_result_fields[] = {
 };
 
 static PyStructSequence_Desc waitid_result_desc = {
-    "waitid_result", /* name */
+    MODNAME ".waitid_result", /* name */
     waitid_result__doc__, /* doc */
     waitid_result_fields,
     5
@@ -8663,7 +8663,7 @@ static PyStructSequence_Field sched_param_fields[] = {
 };
 
 static PyStructSequence_Desc sched_param_desc = {
-    "sched_param", /* name */
+    MODNAME ".sched_param", /* name */
     os_sched_param__doc__, /* doc */
     sched_param_fields,
     1
@@ -11057,7 +11057,7 @@ and elapsed.\n\
 See os.times for more information.");
 
 static PyStructSequence_Desc times_result_desc = {
-    "times_result", /* name */
+    MODNAME ".times_result", /* name */
     times_result__doc__, /* doc */
     times_result_fields,
     5
@@ -18584,14 +18584,12 @@ posixmodule_exec(PyObject *m)
     }
 
 #if defined(HAVE_WAITID)
-    waitid_result_desc.name = MODNAME ".waitid_result";
     state->WaitidResultType = (PyObject *)PyStructSequence_NewType(&waitid_result_desc);
     if (PyModule_AddObjectRef(m, "waitid_result", state->WaitidResultType) < 0) {
         return -1;
     }
 #endif
 
-    stat_result_desc.name = "os.stat_result"; /* see issue #19209 */
     stat_result_desc.fields[7].name = PyStructSequence_UnnamedField;
     stat_result_desc.fields[8].name = PyStructSequence_UnnamedField;
     stat_result_desc.fields[9].name = PyStructSequence_UnnamedField;
@@ -18602,14 +18600,12 @@ posixmodule_exec(PyObject *m)
     state->statresult_new_orig = ((PyTypeObject *)state->StatResultType)->tp_new;
     ((PyTypeObject *)state->StatResultType)->tp_new = statresult_new;
 
-    statvfs_result_desc.name = "os.statvfs_result"; /* see issue #19209 */
     state->StatVFSResultType = (PyObject *)PyStructSequence_NewType(&statvfs_result_desc);
     if (PyModule_AddObjectRef(m, "statvfs_result", state->StatVFSResultType) < 0) {
         return -1;
     }
 
 #if defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)
-    sched_param_desc.name = MODNAME ".sched_param";
     state->SchedParamType = (PyObject *)PyStructSequence_NewType(&sched_param_desc);
     if (PyModule_AddObjectRef(m, "sched_param", state->SchedParamType) < 0) {
         return -1;
@@ -18641,7 +18637,6 @@ posixmodule_exec(PyObject *m)
         return -1;
     }
 
-    times_result_desc.name = MODNAME ".times_result";
     state->TimesResultType = (PyObject *)PyStructSequence_NewType(&times_result_desc);
     if (PyModule_AddObjectRef(m, "times_result", state->TimesResultType) < 0) {
         return -1;