]> granicus.if.org Git - python/commitdiff
Issue #29513: Fix outdated comment and remove redundand code is os.scandir().
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 9 Feb 2017 18:05:51 +0000 (20:05 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 9 Feb 2017 18:05:51 +0000 (20:05 +0200)
Modules/posixmodule.c

index 48c3c7abb4ffa4edae932cf18b22a547a18112ea..ffe4815d66d16a016b11c5923fcf05e7f0488af5 100644 (file)
@@ -11856,7 +11856,6 @@ ScandirIterator_finalize(ScandirIterator *iterator)
         }
     }
 
-    Py_CLEAR(iterator->path.object);
     path_cleanup(&iterator->path);
 
     /* Restore the saved exception. */
@@ -11968,12 +11967,9 @@ os_scandir_impl(PyObject *module, path_t *path)
 #endif
 
     memcpy(&iterator->path, path, sizeof(path_t));
-    /* path_converter doesn't keep path.object around, so do it
-       manually for the lifetime of the iterator here (the refcount
-       is decremented in ScandirIterator_dealloc)
-    */
-    Py_XINCREF(iterator->path.object);
-    Py_XINCREF(iterator->path.cleanup);
+    /* Move the ownership to iterator->path */
+    path->object = NULL;
+    path->cleanup = NULL;
 
 #ifdef MS_WINDOWS
     iterator->first_time = 1;