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: convert os.getcwdu() to os.getcwd(), and getcwdu() to getcwd()
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, loewis, vstinner
Priority: normal Keywords: patch

Created on 2008-10-02 23:22 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_getcwdu.py vstinner, 2008-10-02 23:23
fix_getcwdu-2.patch vstinner, 2008-10-03 10:29
Messages (5)
msg74211 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-10-02 23:22
Python3 removes os.getcwdu() and introduces os.getcwdb(). The patch is 
a fixer for lib2to3 replacing "os.getcwdu()" to "os.getcwd()", 
and "getcwdu()" to "getcwd()". I hope that nobody defined its 
own "getcwdu()" function :-)

Example:
----
cwd = os.getcwdu()
print "cwd=%s" % cwd

from os import getcwdu
cwd = getcwdu()
print "cwd=%s" % cwd
----

Result:
-----
 import os
-cwd = os.getcwdu()
-print "cwd=%s" % cwd
+cwd = os.getcwd()
+print("cwd=%s" % cwd)

-from os import getcwdu
-cwd = getcwdu()
-print "cwd=%s" % cwd
+from os import getcwd
+cwd = getcwd()
+print("cwd=%s" % cwd)
-----
msg74214 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-10-02 23:25
(there is currently no patch attached)

I don't think getcwd() should be fixed as getcwdb(). It's not possible
to tell what the intention of the call was, in which case I recommend
not to change the code at all.
msg74223 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-10-03 02:44
I concur with Martin; getcwd should not be converted to getcwdb.

You're patch looks pretty good. Could you write tests for it, though?
Also, I don't think you need to handle the second case of a bare getcwdu.
msg74235 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-10-03 10:29
Le Friday 03 October 2008 04:44:13 Benjamin Peterson, vous avez écrit :
> You're patch looks pretty good. Could you write tests for it, though?

My patch doesn't work, that's why I don't write unit test :-)
 - os.getcwdu() was correctly replaced
 - getcwdu() was also replaced
 - but not "from os import getcwdu"

Since most people use os.getcwdu(), and that 2to3 is unable to make sure that 
getcwdu() comes from os or is an user defined module, I prefer to only keep 
the first fixer (os.getcwdu() => os.getcwd()). The new patch include a test.

(Let's try Roundup by email using an attachment :-))
msg74281 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-10-03 22:51
Thanks for the patch. Reviewed and applied in r66782.
History
Date User Action Args
2022-04-11 14:56:39adminsetgithub: 48273
2008-10-03 22:51:55benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg74281
2008-10-03 10:29:24vstinnersetfiles: + fix_getcwdu-2.patch
messages: + msg74235
2008-10-03 02:44:11benjamin.petersonsetmessages: + msg74223
2008-10-02 23:25:21loewissetnosy: + loewis
messages: + msg74214
2008-10-02 23:23:51vstinnersetfiles: + fix_getcwdu.py
2008-10-02 23:22:18vstinnercreate