[Python-3000-checkins] r58695 - in python/branches/py3k-pep3137: Doc/includes/noddy2.c Doc/includes/noddy3.c Doc/includes/noddy4.c Doc/includes/run-func.c Lib/email/test/data/msg_15.txt Lib/plat-mac/ic.py Mac/Modules/file/_Filemodule.c Modules/_localemodule.c Modules/_lsprof.c Modules/_sqlite/connection.c Modules/_sqlite/module.c Modules/_testcapimodule.c Modules/pwdmodule.c Objects/exceptions.c Objects/frameobject.c

guido.van.rossum python-3000-checkins at python.org
Sat Oct 27 19:30:08 CEST 2007


Author: guido.van.rossum
Date: Sat Oct 27 19:30:07 2007
New Revision: 58695

Modified:
   python/branches/py3k-pep3137/   (props changed)
   python/branches/py3k-pep3137/Doc/includes/noddy2.c
   python/branches/py3k-pep3137/Doc/includes/noddy3.c
   python/branches/py3k-pep3137/Doc/includes/noddy4.c
   python/branches/py3k-pep3137/Doc/includes/run-func.c
   python/branches/py3k-pep3137/Lib/email/test/data/msg_15.txt
   python/branches/py3k-pep3137/Lib/plat-mac/ic.py
   python/branches/py3k-pep3137/Mac/Modules/file/_Filemodule.c
   python/branches/py3k-pep3137/Modules/_localemodule.c
   python/branches/py3k-pep3137/Modules/_lsprof.c
   python/branches/py3k-pep3137/Modules/_sqlite/connection.c
   python/branches/py3k-pep3137/Modules/_sqlite/module.c
   python/branches/py3k-pep3137/Modules/_testcapimodule.c
   python/branches/py3k-pep3137/Modules/pwdmodule.c
   python/branches/py3k-pep3137/Objects/exceptions.c
   python/branches/py3k-pep3137/Objects/frameobject.c
Log:
Merged revisions 58679-58693 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r58682 | neal.norwitz | 2007-10-26 19:50:52 -0700 (Fri, 26 Oct 2007) | 1 line
  
  Use unicode in more places.  Fixes a problem with str8 + str in test.
........
  r58683 | neal.norwitz | 2007-10-26 19:55:08 -0700 (Fri, 26 Oct 2007) | 6 lines
  
  Get test_email to pass.  There is a problem reading the data file and
  making it unicode with the default encoding.  I'm not sure if this is
  a problem in and of itself.  However, the test seems to be testing
  something different, so at least get that working.  Need to revisit
  the unicode problem.
........
  r58684 | neal.norwitz | 2007-10-26 21:00:45 -0700 (Fri, 26 Oct 2007) | 1 line
  
  Get rid of more uses of string and use unicode
........
  r58685 | neal.norwitz | 2007-10-26 21:01:17 -0700 (Fri, 26 Oct 2007) | 1 line
  
  Try to get this test to pass on Win64 by making clean for ssize_t
........
  r58686 | neal.norwitz | 2007-10-26 22:40:06 -0700 (Fri, 26 Oct 2007) | 4 lines
  
  Get the locale and pwd tests working on the Solaris box where there
  are some unicode values used.  I'm not sure if this is the correct
  on all operating systems, but this works on Linux w/o unicode.
........
  r58687 | neal.norwitz | 2007-10-26 23:04:52 -0700 (Fri, 26 Oct 2007) | 3 lines
  
  Get a bunch of tests working on Mac OS.  I suspect that a bunch of the
  ord()s in Lib/plat-mac/ic.py need to be removed.
........


Modified: python/branches/py3k-pep3137/Doc/includes/noddy2.c
==============================================================================
--- python/branches/py3k-pep3137/Doc/includes/noddy2.c	(original)
+++ python/branches/py3k-pep3137/Doc/includes/noddy2.c	Sat Oct 27 19:30:07 2007
@@ -23,14 +23,14 @@
 
     self = (Noddy *)type->tp_alloc(type, 0);
     if (self != NULL) {
-        self->first = PyString_FromString("");
+        self->first = PyUnicode_FromString("");
         if (self->first == NULL)
           {
             Py_DECREF(self);
             return NULL;
           }
         
-        self->last = PyString_FromString("");
+        self->last = PyUnicode_FromString("");
         if (self->last == NULL)
           {
             Py_DECREF(self);
@@ -90,7 +90,7 @@
     PyObject *args, *result;
 
     if (format == NULL) {
-        format = PyString_FromString("%s %s");
+        format = PyUnicode_FromString("%s %s");
         if (format == NULL)
             return NULL;
     }
@@ -109,7 +109,7 @@
     if (args == NULL)
         return NULL;
 
-    result = PyString_Format(format, args);
+    result = PyUnicode_Format(format, args);
     Py_DECREF(args);
     
     return result;

Modified: python/branches/py3k-pep3137/Doc/includes/noddy3.c
==============================================================================
--- python/branches/py3k-pep3137/Doc/includes/noddy3.c	(original)
+++ python/branches/py3k-pep3137/Doc/includes/noddy3.c	Sat Oct 27 19:30:07 2007
@@ -23,14 +23,14 @@
 
     self = (Noddy *)type->tp_alloc(type, 0);
     if (self != NULL) {
-        self->first = PyString_FromString("");
+        self->first = PyUnicode_FromString("");
         if (self->first == NULL)
           {
             Py_DECREF(self);
             return NULL;
           }
         
-        self->last = PyString_FromString("");
+        self->last = PyUnicode_FromString("");
         if (self->last == NULL)
           {
             Py_DECREF(self);
@@ -93,7 +93,7 @@
     return -1;
   }
   
-  if (! PyString_Check(value)) {
+  if (! PyUnicode_Check(value)) {
     PyErr_SetString(PyExc_TypeError, 
                     "The first attribute value must be a string");
     return -1;
@@ -121,7 +121,7 @@
     return -1;
   }
   
-  if (! PyString_Check(value)) {
+  if (! PyUnicode_Check(value)) {
     PyErr_SetString(PyExc_TypeError, 
                     "The last attribute value must be a string");
     return -1;
@@ -153,7 +153,7 @@
     PyObject *args, *result;
 
     if (format == NULL) {
-        format = PyString_FromString("%s %s");
+        format = PyUnicode_FromString("%s %s");
         if (format == NULL)
             return NULL;
     }
@@ -162,7 +162,7 @@
     if (args == NULL)
         return NULL;
 
-    result = PyString_Format(format, args);
+    result = PyUnicode_Format(format, args);
     Py_DECREF(args);
     
     return result;

Modified: python/branches/py3k-pep3137/Doc/includes/noddy4.c
==============================================================================
--- python/branches/py3k-pep3137/Doc/includes/noddy4.c	(original)
+++ python/branches/py3k-pep3137/Doc/includes/noddy4.c	Sat Oct 27 19:30:07 2007
@@ -57,14 +57,14 @@
 
     self = (Noddy *)type->tp_alloc(type, 0);
     if (self != NULL) {
-        self->first = PyString_FromString("");
+        self->first = PyUnicode_FromString("");
         if (self->first == NULL)
           {
             Py_DECREF(self);
             return NULL;
           }
         
-        self->last = PyString_FromString("");
+        self->last = PyUnicode_FromString("");
         if (self->last == NULL)
           {
             Py_DECREF(self);
@@ -124,7 +124,7 @@
     PyObject *args, *result;
 
     if (format == NULL) {
-        format = PyString_FromString("%s %s");
+        format = PyUnicode_FromString("%s %s");
         if (format == NULL)
             return NULL;
     }
@@ -143,7 +143,7 @@
     if (args == NULL)
         return NULL;
 
-    result = PyString_Format(format, args);
+    result = PyUnicode_Format(format, args);
     Py_DECREF(args);
     
     return result;

Modified: python/branches/py3k-pep3137/Doc/includes/run-func.c
==============================================================================
--- python/branches/py3k-pep3137/Doc/includes/run-func.c	(original)
+++ python/branches/py3k-pep3137/Doc/includes/run-func.c	Sat Oct 27 19:30:07 2007
@@ -13,7 +13,7 @@
     }
 
     Py_Initialize();
-    pName = PyString_FromString(argv[1]);
+    pName = PyUnicode_FromString(argv[1]);
     /* Error checking of pName left out */
 
     pModule = PyImport_Import(pName);

Modified: python/branches/py3k-pep3137/Lib/email/test/data/msg_15.txt
==============================================================================
--- python/branches/py3k-pep3137/Lib/email/test/data/msg_15.txt	(original)
+++ python/branches/py3k-pep3137/Lib/email/test/data/msg_15.txt	Sat Oct 27 19:30:07 2007
@@ -9,7 +9,7 @@
 Content-type: multipart/mixed;
    boundary="MS_Mac_OE_3071477847_720252_MIME_Part"
 
-> Denne meddelelse er i MIME-format. Da dit postl¾sningsprogram ikke forstŒr dette format, kan del af eller hele meddelelsen v¾re ul¾selig.
+> Denne meddelelse er i MIME-format. Da dit postl
 
 --MS_Mac_OE_3071477847_720252_MIME_Part
 Content-type: multipart/alternative;

Modified: python/branches/py3k-pep3137/Lib/plat-mac/ic.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/plat-mac/ic.py	(original)
+++ python/branches/py3k-pep3137/Lib/plat-mac/ic.py	Sat Oct 27 19:30:07 2007
@@ -65,7 +65,7 @@
     return size, face, data[5:5+namelen]
 
 def _decode_boolean(data, key):
-    return ord(data[0])
+    return data[0]
 
 def _decode_text(data, key):
     return data

Modified: python/branches/py3k-pep3137/Mac/Modules/file/_Filemodule.c
==============================================================================
--- python/branches/py3k-pep3137/Mac/Modules/file/_Filemodule.c	(original)
+++ python/branches/py3k-pep3137/Mac/Modules/file/_Filemodule.c	Sat Oct 27 19:30:07 2007
@@ -1312,7 +1312,7 @@
 	        PyMac_Error(err);
 	        return NULL;
 	}
-	_res = PyString_FromString(strbuf);
+	_res = PyUnicode_FromString(strbuf);
 	return _res;
 
 }

Modified: python/branches/py3k-pep3137/Modules/_localemodule.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_localemodule.c	(original)
+++ python/branches/py3k-pep3137/Modules/_localemodule.c	Sat Oct 27 19:30:07 2007
@@ -143,7 +143,7 @@
        involved herein */
 
 #define RESULT_STRING(s)\
-    x = PyUnicode_FromString(l->s);\
+    x = PyUnicode_DecodeUnicodeEscape(l->s, strlen(l->s), "strict");\
     if (!x) goto failed;\
     PyDict_SetItemString(result, #s, x);\
     Py_XDECREF(x)
@@ -471,8 +471,10 @@
             /* Check NULL as a workaround for GNU libc's returning NULL
                instead of an empty string for nl_langinfo(ERA).  */
             const char *result = nl_langinfo(item);
+            result = result != NULL ? result : "";
             /* XXX may have to convert this to wcs first. */
-            return PyUnicode_FromString(result != NULL ? result : "");
+            return PyUnicode_DecodeUnicodeEscape(result, strlen(result),
+                                                 "strict");
         }
     PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant");
     return NULL;

Modified: python/branches/py3k-pep3137/Modules/_lsprof.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_lsprof.c	(original)
+++ python/branches/py3k-pep3137/Modules/_lsprof.c	Sat Oct 27 19:30:07 2007
@@ -179,10 +179,7 @@
 		/* built-in function: look up the module name */
 		PyObject *mod = fn->m_module;
 		const char *modname;
-		if (mod && PyString_Check(mod)) {
-			modname = PyString_AS_STRING(mod);
-		}
-		else if (mod && PyUnicode_Check(mod)) {
+		if (mod && PyUnicode_Check(mod)) {
 			modname = PyUnicode_AsString(mod);
 		}
 		else if (mod && PyModule_Check(mod)) {

Modified: python/branches/py3k-pep3137/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_sqlite/connection.c	(original)
+++ python/branches/py3k-pep3137/Modules/_sqlite/connection.c	Sat Oct 27 19:30:07 2007
@@ -87,7 +87,7 @@
     }
 
     if (!isolation_level) {
-        isolation_level = PyString_FromString("");
+        isolation_level = PyUnicode_FromString("");
         if (!isolation_level) {
             return -1;
         }
@@ -828,24 +828,28 @@
 
         self->inTransaction = 0;
     } else {
+        const char *statement;
+        Py_ssize_t size;
+
         Py_INCREF(isolation_level);
         self->isolation_level = isolation_level;
 
-        begin_statement = PyString_FromString("BEGIN ");
+        begin_statement = PyUnicode_FromString("BEGIN ");
         if (!begin_statement) {
             return -1;
         }
-        PyString_Concat(&begin_statement, isolation_level);
+        PyUnicode_Concat(begin_statement, isolation_level);
         if (!begin_statement) {
             return -1;
         }
 
-        self->begin_statement = PyMem_Malloc(PyString_Size(begin_statement) + 2);
+        statement = PyUnicode_AsStringAndSize(begin_statement, &size);
+        self->begin_statement = PyMem_Malloc(size + 2);
         if (!self->begin_statement) {
             return -1;
         }
 
-        strcpy(self->begin_statement, PyString_AsString(begin_statement));
+        strcpy(self->begin_statement, statement);
         Py_DECREF(begin_statement);
     }
 

Modified: python/branches/py3k-pep3137/Modules/_sqlite/module.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_sqlite/module.c	(original)
+++ python/branches/py3k-pep3137/Modules/_sqlite/module.c	Sat Oct 27 19:30:07 2007
@@ -359,13 +359,13 @@
         Py_DECREF(tmp_obj);
     }
 
-    if (!(tmp_obj = PyString_FromString(PYSQLITE_VERSION))) {
+    if (!(tmp_obj = PyUnicode_FromString(PYSQLITE_VERSION))) {
         goto error;
     }
     PyDict_SetItemString(dict, "version", tmp_obj);
     Py_DECREF(tmp_obj);
 
-    if (!(tmp_obj = PyString_FromString(sqlite3_libversion()))) {
+    if (!(tmp_obj = PyUnicode_FromString(sqlite3_libversion()))) {
         goto error;
     }
     PyDict_SetItemString(dict, "sqlite_version", tmp_obj);

Modified: python/branches/py3k-pep3137/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k-pep3137/Modules/_testcapimodule.c	Sat Oct 27 19:30:07 2007
@@ -5,6 +5,8 @@
  * standard Python regression test, via Lib/test/test_capi.py.
  */
 
+#define PY_SSIZE_T_CLEAN
+
 #include "Python.h"
 #include <float.h>
 #include "structmember.h"
@@ -377,8 +379,8 @@
 {
 	Py_ssize_t value;
 	if (!PyArg_ParseTuple(args, "n", &value))
-	return NULL;
-	return PyInt_FromSsize_t(value);
+		return NULL;
+	return PyLong_FromSsize_t(value);
 }
 
 #ifdef HAVE_LONG_LONG
@@ -465,7 +467,7 @@
 {
 	PyObject *tuple, *obj;
 	Py_UNICODE *value;
-	int len;
+	Py_ssize_t len;
 
         tuple = PyTuple_New(1);
         if (tuple == NULL)
@@ -503,7 +505,7 @@
 {
 	PyObject *tuple, *obj;
 	Py_UNICODE *value1, *value2;
-	int len1, len2;
+	Py_ssize_t len1, len2;
 
         tuple = PyTuple_New(2);
         if (tuple == NULL)

Modified: python/branches/py3k-pep3137/Modules/pwdmodule.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/pwdmodule.c	(original)
+++ python/branches/py3k-pep3137/Modules/pwdmodule.c	Sat Oct 27 19:30:07 2007
@@ -48,8 +48,11 @@
 static void
 sets(PyObject *v, int i, const char* val)
 {
-  if (val)
-	  PyStructSequence_SET_ITEM(v, i, PyUnicode_FromString(val));
+  if (val) {
+	  PyObject *o =
+		PyUnicode_DecodeUnicodeEscape(val, strlen(val), "strict");
+	  PyStructSequence_SET_ITEM(v, i, o);
+  }
   else {
 	  PyStructSequence_SET_ITEM(v, i, Py_None);
 	  Py_INCREF(Py_None);

Modified: python/branches/py3k-pep3137/Objects/exceptions.c
==============================================================================
--- python/branches/py3k-pep3137/Objects/exceptions.c	(original)
+++ python/branches/py3k-pep3137/Objects/exceptions.c	Sat Oct 27 19:30:07 2007
@@ -1882,7 +1882,7 @@
 	    (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
 	PyObject *args_tuple;
 	PyObject *exc_message;
-	exc_message = PyString_FromString("maximum recursion depth exceeded");
+	exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
 	if (!exc_message)
 	    Py_FatalError("cannot allocate argument for RuntimeError "
 			    "pre-allocation");

Modified: python/branches/py3k-pep3137/Objects/frameobject.c
==============================================================================
--- python/branches/py3k-pep3137/Objects/frameobject.c	(original)
+++ python/branches/py3k-pep3137/Objects/frameobject.c	Sat Oct 27 19:30:07 2007
@@ -721,7 +721,7 @@
 	for (j = nmap; --j >= 0; ) {
 		PyObject *key = PyTuple_GET_ITEM(map, j);
 		PyObject *value = values[j];
-		assert(PyString_Check(key)/*XXX this should go*/ || PyUnicode_Check(key));
+		assert(PyUnicode_Check(key));
 		if (deref) {
 			assert(PyCell_Check(value));
 			value = PyCell_GET(value);


More information about the Python-3000-checkins mailing list