changeset 14873:f79d47813b8b

osutil: emulate os.listdir's OSError for long names (issue2898)
author Matt Mackall <mpm@selenic.com>
date Wed, 13 Jul 2011 16:58:51 -0500
parents 15afa4984a94
children d7b424a03627
files mercurial/osutil.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/osutil.c	Wed Jul 13 16:28:46 2011 -0500
+++ b/mercurial/osutil.c	Wed Jul 13 16:58:51 2011 -0500
@@ -12,6 +12,7 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
 
 #ifdef _WIN32
 #include <windows.h>
@@ -288,7 +289,8 @@
 #endif
 
 	if (pathlen >= PATH_MAX) {
-		PyErr_SetString(PyExc_ValueError, "path too long");
+		errno = ENAMETOOLONG;
+		PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
 		goto error_value;
 	}
 	strncpy(fullpath, path, PATH_MAX);