Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30356
Modified Files:
win32file.i
Log Message:
In ConnectEx, allow port to be passed as Unicode
Index: win32file.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v
retrieving revision 1.102
retrieving revision 1.103
diff -C2 -d -r1.102 -r1.103
*** win32file.i 1 Feb 2009 21:11:01 -0000 1.102
--- win32file.i 2 Feb 2009 15:54:26 -0000 1.103
***************
*** 1793,1797 ****
PyObject *hobj = NULL;
PyObject *pobj = (PyObject *)NULL;
! TmpPyObject host_idna;
struct addrinfo hints, *res;
--- 1793,1797 ----
PyObject *hobj = NULL;
PyObject *pobj = (PyObject *)NULL;
! TmpPyObject host_idna, port_idna;
struct addrinfo hints, *res;
***************
*** 1813,1825 ****
return NULL;
}
! if (PyInt_Check(pobj)) {
! PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
! pptr = pbuf;
} else if (PyString_Check(pobj)) {
pptr = PyString_AsString(pobj);
! } else if (pobj == Py_None) {
! pptr = (char *)NULL;
} else {
! PyErr_SetString(PyExc_TypeError, "Int or String expected");
return NULL;
}
--- 1813,1831 ----
return NULL;
}
!
! if (pobj == Py_None) {
! pptr = NULL;
! } else if (PyUnicode_Check(pobj)) {
! port_idna = PyObject_CallMethod(pobj, "encode", "s", "idna");
! if (!port_idna)
! return NULL;
! pptr = PyString_AsString(port_idna);
} else if (PyString_Check(pobj)) {
pptr = PyString_AsString(pobj);
! } else if (PyInt_Check(pobj)) {
! PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
! pptr = pbuf;
} else {
! PyErr_SetString(PyExc_TypeError, "Port must be int, string, or None");
return NULL;
}
|