Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue2722] os.getcwd fails for long path names on linux

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Apr 29, 2008, 5:01 PM

Post #1 of 9 (610 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux

New submission from Jean-Paul Calderone <exarkun [at] divmod>:

$ 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.

----------
components: Library (Lib)
messages: 65987
nosy: exarkun
severity: normal
status: open
title: os.getcwd fails for long path names on linux
versions: Python 2.4

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2008, 6:12 AM

Post #2 of 9 (598 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Changes by Giampaolo Rodola' <billiejoex [at] users>:


----------
nosy: +giampaolo.rodola

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2008, 1:17 PM

Post #3 of 9 (586 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Georg Brandl <georg [at] python> added the comment:

Why isn't the buffer length MAX_PATH anyway?

----------
nosy: +georg.brandl

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2008, 1:19 PM

Post #4 of 9 (586 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Christian Heimes <lists [at] cheimes> added the comment:

It should be MAX_PATH. All path related functions should use MAX_PATH as
buffer size, maybe even MAX_PATH+1

----------
nosy: +tiran

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 2, 2008, 10:09 AM

Post #5 of 9 (574 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Changes by Gregory P. Smith <greg [at] krypto>:


----------
keywords: +easy
nosy: +gregory.p.smith
priority: -> normal

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 7, 2008, 1:01 PM

Post #6 of 9 (558 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Matthias Urlichs <smurf [at] smurf> added the comment:

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.

----------
nosy: +smurfix

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 10, 2008, 6:38 AM

Post #7 of 9 (553 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Neil Blakey-Milner <nbm [at] nxsy> added the comment:

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.

----------
keywords: +patch
nosy: +nbm
versions: +Python 2.5
Added file: http://bugs.python.org/file10240/python-getcwd-dual-strategy.patch

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 10, 2008, 6:41 AM

Post #8 of 9 (551 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Changes by Neil Blakey-Milner <nbm [at] nxsy>:


Added file: http://bugs.python.org/file10241/python-getcwd-malloconly.patch

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 10, 2008, 7:54 AM

Post #9 of 9 (551 views)
Permalink
[issue2722] os.getcwd fails for long path names on linux [In reply to]

Neil Blakey-Milner <nbm [at] nxsy> added the comment:

Here's a patch to add a test that fails with Python 2.5 on OS X, but
passes with either of these patches.

Added file: http://bugs.python.org/file10250/python-getcwd-test_longpathnames.patch

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2722>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.