This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.curdir as the default argument for os.listdir
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, eric.araujo, ezio.melotti, giampaolo.rodola, loewis, michael.foord, rhettinger, tarek, vdupras
Priority: normal Keywords: patch

Created on 2009-05-23 23:54 by tarek, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
t6095.diff vdupras, 2009-06-13 19:42
t6095_2.diff vdupras, 2010-04-18 18:55
t6095_py3k.diff vdupras, 2010-04-19 07:08
Messages (15)
msg88256 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-23 23:54
make os.listdir() path argument be os.curdir.

I am working on a patch, I'll submit here
msg88496 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-05-29 01:58
If this is to go into Py3.1, it needs to happen quickly.
msg89268 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-06-11 23:17
After a deeper look; this change looks rather complex for a posixpath.c
newbie like me.

I probably won't be able to provide it for 3.1. If you want to do it for
3.1, please go ahead Raymond !
msg89337 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2009-06-13 19:42
I saw this ticket as a good way to get my feet wet (I almost never touched 
C) with Python's C API, so I went ahead and did the part for OS X. I also 
did the Windows part, but I'm not setup to compile Python on Windows, so I 
don't even know if it remotely works.

It would be nice if someone could review this patch and tell me about 
mistakes (such as memory management ones, probably). Thanks!
msg89376 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-06-14 23:12
Some comments about the patch:

- It seems wasteful to allocate a new PyUnicode object for the "."; the 
posix implements does it right: a simple wcscopy should be enough (and 
reduces the chances of refcount mistakes)

- the last block is not correctly indented; this code uses tabs.

- no need to test for hasattr(posix, 'listdir'): all supported platforms 
have directories and the posix module always exposes this function.
msg89377 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2009-06-14 23:22
1. Yeah, I know. At first, that's what I wanted to do, but it resulted 
in a lot of code duplication (alloc, memerror, copy), which I didn't 
much like. But then again, what I ended up writing (because I realized I 
had to decref the  new "po") uses up more lines anyway...

2. oops

3. I did it because all other tests do it. I thought there had to be a 
reason (but then again, that old broken "lsdir" test had been there for 
a while...). Even if there's no reason. the new test would really stand 
out compared to the rest...
msg103514 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2010-04-18 18:55
Since I last submitted this patch, my leet C skills have improved.

I'm submitting another patch, without the needless PyUnicode creation this time. (Moreover, I think the previous patch was wrong to insert code before variable declaration of the block)
msg103558 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2010-04-19 07:08
Here's another one. I hadn't realized that it was useless to target the 2.x codebase. So I re-worked this on py3k. The change is non-trivial, since the non-windows/non-os2 part of the code has significantly changed in 3k. This time, since "oname" is released later and used in error conditions, I thought it was worth it to allocate a new PyBytes for the default value.

I also modified the documentation so that it tells about path's default value.
msg111261 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-07-23 10:11
At Europython, we agreed that this functionality is too trivial to add to the standard library; for all practical purposes, os.listdir(".") will do the right thing.

So rejecting this as won't fix.
msg111267 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-07-23 10:29
what do you mean by 'too trivial' ?

I don't understand why this is now suddenly rejected. Raymond, Guido, and other people have +1 this on python-ideas.

http://mail.python.org/pipermail/python-ideas/2009-May/004871.html

People have worked on a patch, so I think this is unfair to close it now without more explanations, and just say that 'we agreed at EP'...
msg111269 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-07-23 10:44
ok, so reopening. Linking to the mailing list would have helped.
msg111272 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-07-23 10:51
Yes, sorry. I should have added the link when I opened the bug. Thanks for reopening it
msg111273 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-07-23 10:57
reopening again sorry (roundup bug)
msg111293 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-07-23 12:21
Thanks for the patch. Committed (with modifications) as r83078.
msg111295 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-07-23 12:25
Thanks for looking into this !
History
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50345
2012-01-12 16:26:00eric.araujosetnosy: + michael.foord

resolution: accepted -> fixed
stage: patch review -> resolved
2010-07-23 12:25:45tareksetmessages: + msg111295
2010-07-23 12:21:19loewissetstatus: open -> closed
resolution: accepted
messages: + msg111293
2010-07-23 10:57:38tareksetstatus: closed -> open
resolution: wont fix -> (no value)
messages: + msg111273
2010-07-23 10:56:55tareksetstatus: open -> closed
nosy: - gvanrossum
resolution: wont fix
2010-07-23 10:53:15tareksetstatus: closed -> open
resolution: wont fix -> (no value)
2010-07-23 10:51:54tareksetstatus: open -> closed
resolution: wont fix
messages: + msg111272
2010-07-23 10:44:58loewissetstatus: closed -> open
resolution: wont fix -> (no value)
messages: + msg111269
2010-07-23 10:34:36eric.araujosetnosy: + eric.araujo
2010-07-23 10:29:49tareksetnosy: + gvanrossum
messages: + msg111267
2010-07-23 10:11:19loewissetstatus: open -> closed

nosy: + loewis
messages: + msg111261

resolution: wont fix
2010-04-19 07:08:53vduprassetfiles: + t6095_py3k.diff

messages: + msg103558
2010-04-19 00:42:34giampaolo.rodolasetnosy: + giampaolo.rodola
2010-04-18 18:55:21vduprassetfiles: + t6095_2.diff

messages: + msg103514
2010-04-18 05:25:08ezio.melottisetnosy: + ezio.melotti

versions: - Python 2.7
2010-01-18 13:47:07ezio.melottisetpriority: normal
stage: patch review
2009-06-14 23:22:34vduprassetmessages: + msg89377
2009-06-14 23:12:38amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg89376
2009-06-13 19:42:51vduprassetfiles: + t6095.diff

nosy: + vdupras
messages: + msg89337

keywords: + patch
2009-06-12 19:15:27rhettingersetversions: + Python 3.2, - Python 3.1
2009-06-11 23:17:02tareksetmessages: + msg89268
2009-05-29 01:58:39rhettingersetnosy: + rhettinger
messages: + msg88496
2009-05-23 23:54:45tarekcreate