Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4403d7de
Commit
4403d7de
authored
Apr 25, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9246: On POSIX, os.getcwd() now supports paths longer than 1025 bytes
Patch written by William Orr.
parent
9bdd6133
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
Misc/NEWS
Misc/NEWS
+3
-0
Modules/posixmodule.c
Modules/posixmodule.c
+27
-7
No files found.
Misc/NEWS
View file @
4403d7de
...
...
@@ -34,6 +34,9 @@ Core and Builtins
Library
-------
- Issue #9246: On POSIX, os.getcwd() now supports paths longer than 1025 bytes.
Patch written by William Orr.
- Issue #23008: Fixed resolving attributes with boolean value is False in pydoc.
- Fix asyncio issue 235: LifoQueue and PriorityQueue'
s
put
didn
't
...
...
Modules/posixmodule.c
View file @
4403d7de
...
...
@@ -3418,12 +3418,15 @@ posix_lchown(PyObject *self, PyObject *args)
static
PyObject
*
posix_getcwd
(
int
use_bytes
)
{
char
buf
[
1026
];
char
*
res
;
char
*
buf
,
*
tmpbuf
;
char
*
cwd
;
const
size_t
chunk
=
1024
;
size_t
buflen
=
0
;
PyObject
*
obj
;
#ifdef MS_WINDOWS
if
(
!
use_bytes
)
{
wchar_t
wbuf
[
1026
];
wchar_t
wbuf
[
MAXPATHLEN
];
wchar_t
*
wbuf2
=
wbuf
;
PyObject
*
resobj
;
DWORD
len
;
...
...
@@ -3457,14 +3460,31 @@ posix_getcwd(int use_bytes)
return
NULL
;
#endif
buf
=
cwd
=
NULL
;
Py_BEGIN_ALLOW_THREADS
res
=
getcwd
(
buf
,
sizeof
buf
);
do
{
buflen
+=
chunk
;
tmpbuf
=
PyMem_RawRealloc
(
buf
,
buflen
);
if
(
tmpbuf
==
NULL
)
break
;
buf
=
tmpbuf
;
cwd
=
getcwd
(
buf
,
buflen
);
}
while
(
cwd
==
NULL
&&
errno
==
ERANGE
);
Py_END_ALLOW_THREADS
if
(
res
==
NULL
)
if
(
cwd
==
NULL
)
{
PyMem_RawFree
(
buf
);
return
posix_error
();
}
if
(
use_bytes
)
return
PyBytes_FromStringAndSize
(
buf
,
strlen
(
buf
));
return
PyUnicode_DecodeFSDefault
(
buf
);
obj
=
PyBytes_FromStringAndSize
(
buf
,
strlen
(
buf
));
else
obj
=
PyUnicode_DecodeFSDefault
(
buf
);
PyMem_RawFree
(
buf
);
return
obj
;
}
PyDoc_STRVAR
(
posix_getcwd__doc__
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment