Issue2722
Created on 2008-04-30 00:01 by exarkun, last changed 2008-06-22 13:37 by facundobatista.
| msg65987 (view) |
Author: Jean-Paul Calderone (exarkun) |
Date: 2008-04-30 00:01 |
|
$ python -c "print len('`pwd`'); import os; print os.getcwd()"
1174
Traceback (most recent call last):
File "<string>", line 1, in ?
OSError: [Errno 34] Numerical result out of range
$
The getcwd man page documents the ERANGE failure and suggests that the
calling application allocate a larger buffer and try again.
|
| msg66021 (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2008-04-30 20:17 |
|
Why isn't the buffer length MAX_PATH anyway?
|
| msg66022 (view) |
Author: Christian Heimes (christian.heimes) |
Date: 2008-04-30 20:19 |
|
It should be MAX_PATH. All path related functions should use MAX_PATH as
buffer size, maybe even MAX_PATH+1
|
| msg66370 (view) |
Author: Matthias Urlichs (smurfix) |
Date: 2008-05-07 20:01 |
|
MAX_PATH is a compile time constant which, like FD_BITS for select(),
may be too small for the system you're ultimately running on.
Using that as default initial size is OK, but handling ERANGE is still a
very good idea.
|
| msg66519 (view) |
Author: Neil Blakey-Milner (nbm) |
Date: 2008-05-10 13:38 |
|
This affects OS X too.
I'm attaching two patches - one uses malloc to build a bigger string if
the existing implementation returns ERANGE, and the other one uses
malloc from the start. This was done on the theory that stack memory
use would be better/more efficient. However, based on testing, there's
no real difference - 16.8usec vs. 17usec - on a rarely-used function.
|
| msg66531 (view) |
Author: Neil Blakey-Milner (nbm) |
Date: 2008-05-10 14:54 |
|
Here's a patch to add a test that fails with Python 2.5 on OS X, but
passes with either of these patches.
|
| msg68563 (view) |
Author: Facundo Batista (facundobatista) |
Date: 2008-06-22 13:37 |
|
Went for the malloc only patch. Just fixed a small detail (weird corner
case if malloc returned NULL first time, res will be unassigned).
The test could be better (no necessity of using a recursive function, it
could be done with a while), but it works.
Commited in r64452.
|
|
| Date |
User |
Action |
Args |
| 2008-06-22 13:37:12 | facundobatista | set | status: open -> closed nosy:
+ facundobatista resolution: fixed messages:
+ msg68563 |
| 2008-05-10 14:54:40 | nbm | set | files:
+ python-getcwd-test_longpathnames.patch messages:
+ msg66531 |
| 2008-05-10 13:41:21 | nbm | set | files:
+ python-getcwd-malloconly.patch |
| 2008-05-10 13:38:16 | nbm | set | files:
+ python-getcwd-dual-strategy.patch nosy:
+ nbm messages:
+ msg66519 keywords:
+ patch versions:
+ Python 2.5 |
| 2008-05-07 20:01:58 | smurfix | set | nosy:
+ smurfix messages:
+ msg66370 |
| 2008-05-02 17:09:42 | gregory.p.smith | set | priority: normal nosy:
+ gregory.p.smith keywords:
+ easy |
| 2008-04-30 20:19:51 | christian.heimes | set | nosy:
+ christian.heimes messages:
+ msg66022 |
| 2008-04-30 20:17:57 | georg.brandl | set | nosy:
+ georg.brandl messages:
+ msg66021 |
| 2008-04-30 13:12:00 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola |
| 2008-04-30 00:01:51 | exarkun | create | |
|