Skip to content

Commit c31ebb6

Browse files
committed
(Merge 3.3) fileutils.c: use MAXPATHLEN instead of PATH_MAX
PATH_MAX is not declared on IRIX nor Windows.
2 parents 50e0157 + b11d6cb commit c31ebb6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/fileutils.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ int
869869
_Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
870870
{
871871
char *cpath;
872-
char cbuf[PATH_MAX];
872+
char cbuf[MAXPATHLEN];
873873
wchar_t *wbuf;
874874
int res;
875875
size_t r1;
@@ -879,11 +879,11 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
879879
errno = EINVAL;
880880
return -1;
881881
}
882-
res = (int)readlink(cpath, cbuf, PATH_MAX);
882+
res = (int)readlink(cpath, cbuf, Py_ARRAY_LENGTH(cbuf));
883883
PyMem_Free(cpath);
884884
if (res == -1)
885885
return -1;
886-
if (res == PATH_MAX) {
886+
if (res == Py_ARRAY_LENGTH(cbuf)) {
887887
errno = EINVAL;
888888
return -1;
889889
}
@@ -915,7 +915,7 @@ _Py_wrealpath(const wchar_t *path,
915915
wchar_t *resolved_path, size_t resolved_path_size)
916916
{
917917
char *cpath;
918-
char cresolved_path[PATH_MAX];
918+
char cresolved_path[MAXPATHLEN];
919919
wchar_t *wresolved_path;
920920
char *res;
921921
size_t r;
@@ -956,11 +956,11 @@ _Py_wgetcwd(wchar_t *buf, size_t size)
956956
int isize = (int)Py_MIN(size, INT_MAX);
957957
return _wgetcwd(buf, isize);
958958
#else
959-
char fname[PATH_MAX];
959+
char fname[MAXPATHLEN];
960960
wchar_t *wname;
961961
size_t len;
962962

963-
if (getcwd(fname, PATH_MAX) == NULL)
963+
if (getcwd(fname, Py_ARRAY_LENGTH(fname)) == NULL)
964964
return NULL;
965965
wname = _Py_char2wchar(fname, &len);
966966
if (wname == NULL)

0 commit comments

Comments
 (0)