[Python-3000-checkins] r56510 - python/branches/py3k-struni/Mac/Modules/file/_Filemodule.c

guido.van.rossum python-3000-checkins at python.org
Mon Jul 23 19:08:22 CEST 2007


Author: guido.van.rossum
Date: Mon Jul 23 19:08:21 2007
New Revision: 56510

Modified:
   python/branches/py3k-struni/Mac/Modules/file/_Filemodule.c
Log:
SF patch# 1758570 by Jeffrey Yasskin, who writes:
I made Carbon.File.pathname return unicode, by analogy with
macpath.abspath. There could easily be other bugs of the same sort in this
file. The uses of PyString_FromString*() in particular look sketchy.


Modified: python/branches/py3k-struni/Mac/Modules/file/_Filemodule.c
==============================================================================
--- python/branches/py3k-struni/Mac/Modules/file/_Filemodule.c	(original)
+++ python/branches/py3k-struni/Mac/Modules/file/_Filemodule.c	Mon Jul 23 19:08:21 2007
@@ -3033,12 +3033,8 @@
 
 	if (!PyArg_ParseTuple(_args, "O", &obj))
 	        return NULL;
-	if (PyString_Check(obj)) {
-	        Py_INCREF(obj);
-	        return obj;
-	}
-	if (PyUnicode_Check(obj))
-	        return PyUnicode_AsEncodedString(obj, "utf8", "strict");
+	if (PyString_Check(obj) || PyUnicode_Check(obj))
+		return PyUnicode_FromObject(obj);
 	_res = PyObject_CallMethod(obj, "as_pathname", NULL);
 	return _res;
 
@@ -3140,7 +3136,7 @@
 	{"FSUpdateAlias", (PyCFunction)File_FSUpdateAlias, 1,
 	 PyDoc_STR("(FSRef fromFile, FSRef target, AliasHandle alias) -> (Boolean wasChanged)")},
 	{"pathname", (PyCFunction)File_pathname, 1,
-	 PyDoc_STR("(str|unicode|FSSpec|FSref) -> pathname")},
+	 PyDoc_STR("(str|FSSpec|FSref) -> pathname")},
 	{NULL, NULL, 0}
 };
 


More information about the Python-3000-checkins mailing list