--- a/mercurial/osutil.c Thu Mar 09 12:09:31 2017 -0800
+++ b/mercurial/osutil.c Wed Mar 15 20:43:12 2017 -0700
@@ -400,6 +400,8 @@
Py_XDECREF(stat);
error_list:
closedir(dir);
+ /* closedir also closes its dirfd */
+ goto error_value;
error_dir:
#ifdef AT_SYMLINK_NOFOLLOW
close(dfd);