[Python-Dev] 2.2a3 oddities

Guido van Rossum guido@python.org
Fri, 07 Sep 2001 15:56:36 -0400


> > 2) most C functions that expect 8-bit strings crash if you
> > hand them a unicode string containing non-ascii characters.
> > 
> > an example:
> > 
> > >>> import socket
> > >>> socket.gethostbyname(u"pyth�nware.com")
> > 
> > this works as expected in 2.1.1 (that is, I get an exception).
> > it doesn't work in a local build of 2.2a2.
> 
> Yes, confirmed in 2.2a3 :-(
> 
> Tim?  Time for a debug session?

Never mind, Tim. :-)

This crashes on Linux too.  This patch fixes it, but I'm not sure if
that's right -- more eyes, please?  (Maybe the fix is simpler and it
should just replace the test for Py_None with a test for NULL?)

Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.63
diff -c -r2.63 getargs.c
*** getargs.c	2001/08/28 16:37:51	2.63
--- getargs.c	2001/09/07 19:56:21
***************
*** 369,374 ****
--- 369,375 ----
  {
  	assert (expected != NULL);
  	sprintf(msgbuf, "must be %.50s, not %.50s", expected,
+ 		arg == NULL ? "NULL" :
  		arg == Py_None ? "None" : arg->ob_type->tp_name);
  	return msgbuf;
  }


--Guido van Rossum (home page: http://www.python.org/~guido/)