[Python-3000-checkins] r58780 - in python/branches/py3k-pep3137: Lib/test/test_posix.py Modules/posixmodule.c
guido.van.rossum
python-3000-checkins at python.org
Fri Nov 2 18:18:22 CET 2007
Author: guido.van.rossum
Date: Fri Nov 2 18:18:22 2007
New Revision: 58780
Modified:
python/branches/py3k-pep3137/Lib/test/test_posix.py
python/branches/py3k-pep3137/Modules/posixmodule.c
Log:
Ensure that posix.environ maps strings to strings.
For now, keys and values that aren't UTF-8 are simply ignored.
Modified: python/branches/py3k-pep3137/Lib/test/test_posix.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_posix.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_posix.py Fri Nov 2 18:18:22 2007
@@ -193,6 +193,11 @@
if hasattr(st, 'st_flags'):
posix.lchflags(test_support.TESTFN, st.st_flags)
+ def test_environ(self):
+ for k, v in posix.environ.items():
+ self.assertEqual(type(k), str)
+ self.assertEqual(type(v), str)
+
def test_main():
test_support.run_unittest(PosixTester)
Modified: python/branches/py3k-pep3137/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/posixmodule.c (original)
+++ python/branches/py3k-pep3137/Modules/posixmodule.c Fri Nov 2 18:18:22 2007
@@ -357,12 +357,12 @@
char *p = strchr(*e, '=');
if (p == NULL)
continue;
- k = PyString_FromStringAndSize(*e, (int)(p-*e));
+ k = PyUnicode_FromStringAndSize(*e, (int)(p-*e));
if (k == NULL) {
PyErr_Clear();
continue;
}
- v = PyString_FromString(p+1);
+ v = PyUnicode_FromString(p+1);
if (v == NULL) {
PyErr_Clear();
Py_DECREF(k);
More information about the Python-3000-checkins
mailing list