pywin32-checkins Mailing List for Python for Windows Extensions (Page 67)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Roger U. <ru...@us...> - 2008-09-17 03:51:12
|
Update of /cvsroot/pywin32/pywin32/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18146 Removed Files: Tag: py3k dbi.dsp Log Message: Remove dbi module --- dbi.dsp DELETED --- |
From: Roger U. <ru...@us...> - 2008-09-17 03:50:10
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17709 Removed Files: Tag: py3k dbi.cpp dbi.def dbi.h Log Message: Remove dbi module --- dbi.h DELETED --- --- dbi.cpp DELETED --- --- dbi.def DELETED --- |
From: Roger U. <ru...@us...> - 2008-09-17 03:47:22
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16448 Modified Files: Tag: py3k setup.py Log Message: Remove dbi module Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.81.2.1 retrieving revision 1.81.2.2 diff -C2 -d -r1.81.2.1 -r1.81.2.2 *** setup.py 29 Aug 2008 05:41:39 -0000 1.81.2.1 --- setup.py 17 Sep 2008 03:47:32 -0000 1.81.2.2 *************** *** 1277,1283 **** for info in ( - ("dbi", "", True), ("mmapfile", "", True), ! ("odbc", "odbc32 odbccp32 dbi", True), ("perfmon", "", True), ("timer", "user32", True), --- 1277,1282 ---- for info in ( ("mmapfile", "", True), ! ("odbc", "odbc32 odbccp32", True), ("perfmon", "", True), ("timer", "user32", True), |
From: Roger U. <ru...@us...> - 2008-09-17 03:21:01
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5902 Modified Files: Tag: py3k test_odbc.py Log Message: Add tests for raw binary field and extended unicode chars Index: test_odbc.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_odbc.py,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** test_odbc.py 24 May 2007 05:38:35 -0000 1.7 --- test_odbc.py 17 Sep 2008 03:21:09 -0000 1.7.2.1 *************** *** 4,8 **** import unittest import odbc - import dbi import tempfile --- 4,7 ---- *************** *** 33,37 **** pass else: ! raise RuntimeError, "Can't find a DB engine" workspace = dbe.Workspaces(0) --- 32,36 ---- pass else: ! raise RuntimeError("Can't find a DB engine") workspace = dbe.Workspaces(0) *************** *** 50,63 **** try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, dbi.progError): pass self.assertEqual(self.cur.execute( """create table pywin32test_users ( ! userid varchar(5), username varchar(25), ! bitfield bit, intfield integer, floatfield float, datefield date, ! )"""),-1) def tearDown(self): --- 49,65 ---- try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, odbc.progError): pass self.assertEqual(self.cur.execute( """create table pywin32test_users ( ! userid varchar(25), ! username varchar(25), ! bitfield bit, ! intfield integer, floatfield float, datefield date, ! rawfield varbinary(100) ! )"""),-1) def tearDown(self): *************** *** 65,70 **** try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, dbi.progError), why: ! print "Failed to delete test table:", why self.cur.close() --- 67,72 ---- try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, odbc.progError) as why: ! print ("Failed to delete test table:", why) self.cur.close() *************** *** 89,96 **** try: self.test_insert_select(userid='Frank' * 200, username='Frank Millman' * 200) ! except dbi.noError: pass ! def test_insert_select_unicode(self, userid=u'Frank', username=u"Frank Millman"): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid, username)\ values (?,?)", [userid, username]),1) --- 91,98 ---- try: self.test_insert_select(userid='Frank' * 200, username='Frank Millman' * 200) ! except odbc.noError: pass ! def test_insert_select_unicode(self, userid='Frank', username="Frank Millman"): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid, username)\ values (?,?)", [userid, username]),1) *************** *** 101,106 **** def test_insert_select_unicode_ext(self): ! userid = unicode("t-\xe0\xf2", "mbcs") ! username = unicode("test-\xe0\xf2 name", "mbcs") self.test_insert_select_unicode(userid, username) --- 103,108 ---- def test_insert_select_unicode_ext(self): ! userid = str(b"t-\xe0\xf2", "mbcs") ! username = str(b"test-\xe0\xf2 name", "mbcs") self.test_insert_select_unicode(userid, username) *************** *** 124,129 **** self._test_val('intfield', 1) self._test_val('intfield', 0) ! self._test_val('intfield', sys.maxint) ! def testFloat(self): self._test_val('floatfield', 1.01) --- 126,131 ---- self._test_val('intfield', 1) self._test_val('intfield', 0) ! self._test_val('intfield', sys.maxsize) ! def testFloat(self): self._test_val('floatfield', 1.01) *************** *** 133,136 **** --- 135,148 ---- self._test_val('username', 'foo') + def testRaw(self): + ## Test binary data + self._test_val('rawfield', memoryview(b'\1\2\3\4\0\5\6\7\8')) + + def test_widechar(self): + """Test a unicode character that would be mangled if bound as plain character. + For example, previously the below was returned as ascii 'a' + """ + self._test_val('username', '\u0101') + def testDates(self): import datetime *************** *** 139,143 **** ): d = datetime.datetime(*v) ! self._test_val('datefield', 'd') def test_set_nonzero_length(self): --- 151,155 ---- ): d = datetime.datetime(*v) ! self._test_val('datefield', d) def test_set_nonzero_length(self): *************** *** 151,155 **** def test_set_zero_length(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",['Frank', '']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) --- 163,167 ---- def test_set_zero_length(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",[b'Frank', '']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) *************** *** 157,161 **** def test_set_zero_length_unicode(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",[u'Frank', u'']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) --- 169,173 ---- def test_set_zero_length_unicode(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",['Frank', '']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) |
From: Roger U. <ru...@us...> - 2008-09-17 03:17:33
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4188 Modified Files: Tag: py3k odbc.cpp Log Message: Bind VARCHAR fields as SQL_C_WCHAR so they can be returned as native unicode Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.6 retrieving revision 1.20.2.7 diff -C2 -d -r1.20.2.6 -r1.20.2.7 *** odbc.cpp 16 Sep 2008 15:14:05 -0000 1.20.2.6 --- odbc.cpp 17 Sep 2008 03:17:42 -0000 1.20.2.7 *************** *** 600,607 **** } static PyObject *stringCopy(const void *v, int sz) { ! return Py_BuildValue("s", v); } static PyObject *longCopy(const void *v, int sz) { --- 600,613 ---- } + static PyObject *wcharCopy(const void *v, int sz) + { + return PyWinObject_FromWCHAR((WCHAR *)v, sz/sizeof(WCHAR)); + } + static PyObject *stringCopy(const void *v, int sz) { ! return PyString_FromStringAndSize((char *)v, sz); } + static PyObject *longCopy(const void *v, int sz) { *************** *** 1275,1280 **** typeOf = DbiRaw; break; case SQL_LONGVARCHAR: ! bindOutputVar(cur, stringCopy, SQL_C_CHAR, cur->max_width, pos, true); typeOf = DbiString; break; --- 1281,1289 ---- typeOf = DbiRaw; break; + case SQL_VARCHAR: + case SQL_WVARCHAR: case SQL_LONGVARCHAR: ! case SQL_WLONGVARCHAR: ! bindOutputVar(cur, wcharCopy, SQL_C_WCHAR, cur->max_width, pos, true); typeOf = DbiString; break; |
From: Roger U. <ru...@us...> - 2008-09-16 15:13:56
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4812 Modified Files: Tag: py3k odbc.cpp Log Message: Accept and return raw binary fields as buffers Remove last dependencies on dbi module Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.5 retrieving revision 1.20.2.6 diff -C2 -d -r1.20.2.5 -r1.20.2.6 *** odbc.cpp 16 Sep 2008 01:01:17 -0000 1.20.2.5 --- odbc.cpp 16 Sep 2008 15:14:05 -0000 1.20.2.6 *************** *** 36,44 **** // #endif ! #include "dbi.h" /*$ This is a hack */ ! static PyObject *odbcError; static PyObject *datetime_module, *datetime_class; ! #define MAX_STR 45 static HENV Env; --- 36,50 ---- // #endif ! static PyObject *datetime_module, *datetime_class; ! // Type names ! static PyObject *DbiString, *DbiRaw, *DbiNumber, *DbiDate; ! // Exceptions ! static PyObject *odbcError; ! static PyObject *DbiNoError, *DbiOpError, *DbiProgError; ! static PyObject *DbiIntegrityError, *DbiDataError, *DbiInternalError; ! ! #define MAX_STR 256 static HENV Env; *************** *** 621,625 **** static PyObject *rawCopy(const void *v, int sz) { ! return dbiMakeRaw(PyString_FromStringAndSize((char *)v, sz)); } --- 627,642 ---- static PyObject *rawCopy(const void *v, int sz) { ! PyObject *ret = PyBuffer_New(sz); ! if (!ret) ! return NULL; ! void *buf; ! DWORD buflen; ! // Should not fail, but check anyway ! if (!PyWinObject_AsWriteBuffer(ret, &buf, &buflen)){ ! Py_DECREF(ret); ! return NULL; ! } ! memcpy(buf, v, sz); ! return ret; } *************** *** 753,762 **** } else{ ! long long longlongval = PyLong_AsLongLong(item); if (longlongval == -1 && PyErr_Occurred()) return 0; CType = SQL_C_SBIGINT; SqlType = SQL_BIGINT; ! len = sizeof(long long); ib = initInputBinding(cur, len); if (!ib) --- 770,779 ---- } else{ ! __int64 longlongval = PyLong_AsLongLong(item); if (longlongval == -1 && PyErr_Occurred()) return 0; CType = SQL_C_SBIGINT; SqlType = SQL_BIGINT; ! len = sizeof(longlongval); ib = initInputBinding(cur, len); if (!ib) *************** *** 881,887 **** static int ibindRaw(cursorObject *cur, int column, PyObject *item) { ! const char *val = PyString_AsString(item); ! Py_ssize_t len = PyObject_Length(item); ! InputBinding *ib = initInputBinding(cur, len); if (!ib) --- 898,905 ---- static int ibindRaw(cursorObject *cur, int column, PyObject *item) { ! void *val; ! DWORD len; ! if (!PyWinObject_AsReadBuffer(item, &val, &len)) ! return 0; InputBinding *ib = initInputBinding(cur, len); if (!ib) *************** *** 1065,1073 **** item = PySequence_GetItem(vars, i); iCol = i + 1; ! if (dbiIsRaw(item)) ! { ! rv = ibindRaw(cur, iCol, dbiValue(item)); ! } ! else if (PyLong_Check(item)) { rv = ibindLong(cur, iCol, item); --- 1083,1087 ---- item = PySequence_GetItem(vars, i); iCol = i + 1; ! if (PyLong_Check(item)) { rv = ibindLong(cur, iCol, item); *************** *** 1097,1102 **** --- 1111,1127 ---- rv = ibindDate(cur, iCol, item); } + #if (PY_VERSION_HEX < 0x03000000) + else if (PyBuffer_Check(item)) + #else + else if (PyObject_CheckReadBuffer(item)) + #endif + { + rv = ibindRaw(cur, iCol, item); + } else { + OutputDebugString(_T("bindInput - using repr conversion for type: '")); + OutputDebugStringA(item->ob_type->tp_name); + OutputDebugString(_T("'\n")); PyObject *sitem = PyObject_Str(item); if (sitem==NULL) *************** *** 1956,1961 **** if (!dict) RETURN_ERROR; - if (!PyImport_ImportModule("dbi")) - RETURN_ERROR; // Sql dates are now returned as python's datetime object. --- 1981,1984 ---- *************** *** 1974,1981 **** } odbcError = PyErr_NewException("odbc.odbcError", NULL, NULL); if (odbcError == NULL || PyDict_SetItemString(dict, "error", odbcError) == -1) RETURN_ERROR; ! /* The indices go to indices in the ODBC error table */ dbiErrors[0] = DbiNoError; --- 1997,2050 ---- } + /* Names of various sql datatypes. + 's' format of Py_BuildValue creates unicode on py3k, and char string on 2.x + */ + char *szDbiString = "STRING"; + char *szDbiRaw = "RAW"; + char *szDbiNumber = "NUMBER"; + char *szDbiDate = "DATE"; + PyObject *obtypes=Py_BuildValue("(ssss)", + szDbiString, + szDbiRaw, + szDbiNumber, + szDbiDate); + // Steals a ref to obtypes, so it doesn't need to be DECREF'ed. + if (obtypes==NULL || PyModule_AddObject(module, "TYPES", obtypes) == -1) + RETURN_ERROR; + DbiString = PyTuple_GET_ITEM(obtypes, 0); + DbiRaw = PyTuple_GET_ITEM(obtypes, 1); + DbiNumber = PyTuple_GET_ITEM(obtypes, 2); + DbiDate = PyTuple_GET_ITEM(obtypes, 3); + /* ??? These are also added to the module with attribute name same as value, + not sure what the point of this is ??? + */ + if (PyDict_SetItem(dict, DbiString, DbiString) == -1 + ||PyDict_SetItem(dict, DbiRaw, DbiRaw) == -1 + ||PyDict_SetItem(dict, DbiNumber, DbiNumber) == -1 + ||PyDict_SetItem(dict, DbiDate, DbiDate) == -1) + RETURN_ERROR; + + // Initialize various exception types odbcError = PyErr_NewException("odbc.odbcError", NULL, NULL); if (odbcError == NULL || PyDict_SetItemString(dict, "error", odbcError) == -1) RETURN_ERROR; ! DbiNoError = PyErr_NewException("dbi.noError", NULL, NULL); ! if (DbiNoError == NULL || PyDict_SetItemString(dict, "noError", DbiNoError) == -1) ! RETURN_ERROR; ! DbiOpError = PyErr_NewException("dbi.opError", NULL, NULL); ! if (DbiOpError == NULL || PyDict_SetItemString(dict, "opError", DbiOpError) == -1) ! RETURN_ERROR; ! DbiProgError = PyErr_NewException("dbi.progError", NULL, NULL); ! if (DbiProgError == NULL || PyDict_SetItemString(dict, "progError", DbiProgError) == -1) ! RETURN_ERROR; ! DbiIntegrityError = PyErr_NewException("dbi.integrityError", NULL, NULL); ! if (DbiIntegrityError == NULL || PyDict_SetItemString(dict, "integrityError", DbiIntegrityError) == -1) ! RETURN_ERROR; ! DbiDataError = PyErr_NewException("dbi.dataError", NULL, NULL); ! if (DbiDataError == NULL || PyDict_SetItemString(dict, "dataError", DbiDataError) == -1) ! RETURN_ERROR; ! DbiInternalError = PyErr_NewException("dbi.internalError", NULL, NULL); ! if (DbiInternalError == NULL || PyDict_SetItemString(dict, "internalError", DbiInternalError) == -1) ! RETURN_ERROR; /* The indices go to indices in the ODBC error table */ dbiErrors[0] = DbiNoError; |
From: Roger U. <ru...@us...> - 2008-09-16 01:07:13
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31183 Modified Files: Tag: py3k ToDo.txt Log Message: Couple more things taken care of Index: ToDo.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/Attic/ToDo.txt,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** ToDo.txt 7 Sep 2008 04:14:36 -0000 1.1.2.6 --- ToDo.txt 16 Sep 2008 01:07:20 -0000 1.1.2.7 *************** *** 1,6 **** Some things that still need work for Python 3.0 - - - odbc - input binding needs changes for longs, use SQL_C_LONG instead SQL_C_SBIGINT if value fits in a long Swig doesn't handle com_interface_parent, adsi will not build --- 1,3 ---- *************** *** 11,16 **** but __argv is NULL - pythoncom - Get*String routines for looking up error codes return bytes instead of unicode - Pythonwin - xxx LVITEM and TVITEM conversions use PyWinobject_AsTCHAR, result needs to be freed --- 8,11 ---- *************** *** 34,40 **** as they will be very similar to tp_new for created type ! ! ! Pasted text ends up with empty lines Autoindent gets spaces/tabs wrong --- 29,35 ---- as they will be very similar to tp_new for created type ! xxx Pasted text ends up with empty lines ! Need to define scintilla line ending alongside default_scintilla_encoding, ! can be switched using SCI_SETEOLMODE with SC_EOL_LF Autoindent gets spaces/tabs wrong |
From: Roger U. <ru...@us...> - 2008-09-16 01:01:07
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28795 Modified Files: Tag: py3k dbi.cpp dbi.def dbi.h odbc.cpp Log Message: Return sql dates as datetime objects Remove dbiDate and dbiRowId (with an eye toward removing dbi module altogether) Index: dbi.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/dbi.h,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** dbi.h 13 Jul 2004 05:15:00 -0000 1.4 --- dbi.h 16 Sep 2008 01:01:17 -0000 1.4.4.1 *************** *** 22,34 **** #endif - DBI_FUNC(int) dbiIsDate(const PyObject *o); DBI_FUNC(int) dbiIsRaw(const PyObject *o); - DBI_FUNC(int) dbiIsRowId(const PyObject *o); /* These do not INCREF */ DBI_FUNC(PyObject) *dbiValue(PyObject *o); - DBI_FUNC(PyObject) *dbiMakeDate(PyObject *contents); DBI_FUNC(PyObject) *dbiMakeRaw(PyObject *contents); - DBI_FUNC(PyObject) *dbiMakeRowId(PyObject *contents); DBI_FUNC(PyObject)*DbiString; --- 22,30 ---- Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.4 retrieving revision 1.20.2.5 diff -C2 -d -r1.20.2.4 -r1.20.2.5 *** odbc.cpp 15 Sep 2008 07:46:37 -0000 1.20.2.4 --- odbc.cpp 16 Sep 2008 01:01:17 -0000 1.20.2.5 *************** *** 16,19 **** --- 16,20 ---- #include "PyWinTypes.h" + #include "PyWinObjects.h" #include "structmember.h" *************** *** 37,40 **** --- 38,42 ---- #include "dbi.h" /*$ This is a hack */ static PyObject *odbcError; + static PyObject *datetime_module, *datetime_class; #define MAX_STR 45 *************** *** 611,623 **** { const TIMESTAMP_STRUCT *dt = (const TIMESTAMP_STRUCT *) v; ! struct tm gt; ! gt.tm_isdst = -1; /* figure out DST */ ! gt.tm_year = dt->year-1900; ! gt.tm_mon = dt->month-1; ! gt.tm_mday = dt->day; ! gt.tm_hour = dt->hour; ! gt.tm_min = dt->minute; ! gt.tm_sec = dt->second; ! return dbiMakeDate(PyLong_FromLongLong(mktime(>))); } --- 613,620 ---- { const TIMESTAMP_STRUCT *dt = (const TIMESTAMP_STRUCT *) v; ! return PyObject_CallFunction(datetime_class, "hhhhhhl", ! dt->year, dt->month, dt->day, ! dt->hour, dt->minute, dt->second, dt->fraction); ! // ??? Not sure what units fraction uses ??? } *************** *** 819,839 **** static int ibindDate(cursorObject*cur, int column, PyObject *item) { - long val = PyInt_AsLong(item); int len = sizeof(TIMESTAMP_STRUCT); - InputBinding *ib = initInputBinding(cur, len); if (!ib) return 0; - TIMESTAMP_STRUCT *dt = (TIMESTAMP_STRUCT*) ib->bind_area ; ! struct tm *gt = localtime((const time_t *)&val); ! ! dt->year = 1900 + gt->tm_year; ! dt->month = gt->tm_mon + 1; ! dt->day = gt->tm_mday; ! dt->hour = gt->tm_hour; ! dt->minute = gt->tm_min; ! dt->second = gt->tm_sec; ! dt->fraction = 0; if (unsuccessful(SQLBindParameter( --- 816,862 ---- static int ibindDate(cursorObject*cur, int column, PyObject *item) { int len = sizeof(TIMESTAMP_STRUCT); InputBinding *ib = initInputBinding(cur, len); if (!ib) return 0; TIMESTAMP_STRUCT *dt = (TIMESTAMP_STRUCT*) ib->bind_area ; ! ZeroMemory(dt, sizeof(*dt)); ! // Accept either a PyTime or datetime object ! if (PyTime_Check(item)){ ! SYSTEMTIME st; ! if (!((PyTime *)item)->GetTime(&st)) ! return 0; ! dt->year = st.wYear; ! dt->month = st.wMonth; ! dt->day = st.wDay; ! dt->hour = st.wHour; ! dt->minute = st.wMinute; ! dt->second = st.wSecond; ! dt->fraction = st.wMilliseconds; ! // ??? Not sure what units fraction is in ??? ! } ! else{ ! // Python 2.3 doesn't have C Api for datetime ! PyObject *timeseq = PyObject_CallMethod(item, "timetuple", NULL); ! if (timeseq==NULL) ! return 0; ! PyObject *timetuple=PySequence_Tuple(timeseq); ! if (timetuple==NULL){ ! Py_DECREF(timeseq); ! return 0; ! } ! // Last 3 items are ignored. Need to figure out how to get fractional seconds also. ! PyObject *obwday, *obyday, *obdst; ! if (!PyArg_ParseTuple(timetuple, "hhh|hhhOOO:TIMESTAMP_STRUCT", ! &dt->year, &dt->month, &dt->day, ! &dt->hour, &dt->minute, &dt->second, ! &obwday, &obyday, &obdst)){ ! Py_DECREF(timeseq); ! Py_DECREF(timetuple); ! return 0; ! } ! Py_DECREF(timeseq); ! Py_DECREF(timetuple); ! } if (unsuccessful(SQLBindParameter( *************** *** 965,969 **** { const WCHAR *wval = (WCHAR *)PyUnicode_AsUnicode(item); ! Py_ssize_t nchars = PyUnicode_GetSize(item); Py_ssize_t nbytes = nchars * sizeof(WCHAR); --- 988,992 ---- { const WCHAR *wval = (WCHAR *)PyUnicode_AsUnicode(item); ! Py_ssize_t nchars = PyUnicode_GetSize(item) + 1; Py_ssize_t nbytes = nchars * sizeof(WCHAR); *************** *** 972,976 **** return 0; ! wcscpy((WCHAR *)ib->bind_area, wval); /* See above re SQL_VARCHAR */ int sqlType = SQL_WVARCHAR; --- 995,999 ---- return 0; ! wcsncpy((WCHAR *)ib->bind_area, wval, nchars); /* See above re SQL_VARCHAR */ int sqlType = SQL_WVARCHAR; *************** *** 1045,1052 **** { rv = ibindRaw(cur, iCol, dbiValue(item)); - } - else if (dbiIsDate(item)) - { - rv = ibindDate(cur, iCol, dbiValue(item)); } else if (PyLong_Check(item)) --- 1068,1071 ---- *************** *** 1074,1077 **** --- 1093,1100 ---- rv = ibindFloat(cur, iCol, item); } + else if (PyTime_Check(item) || PyObject_HasAttrString(item, "timetuple")) + { + rv = ibindDate(cur, iCol, item); + } else { *************** *** 1241,1246 **** } new_tuple = Py_BuildValue( ! "(sOiiiii)", ! name, typeOf, dsize, (int)vsize, prec, scale, nullok); --- 1264,1269 ---- } new_tuple = Py_BuildValue( ! "(NOiiiii)", ! PyWinObject_FromTCHAR(name), typeOf, dsize, (int)vsize, prec, scale, nullok); *************** *** 1936,1939 **** --- 1959,1971 ---- RETURN_ERROR; + // Sql dates are now returned as python's datetime object. + // C Api for datetime didn't exist in 2.3, stick to dynamic semantics for now. + datetime_module=PyImport_ImportModule("datetime"); + if (datetime_module == NULL) + RETURN_ERROR; + datetime_class = PyObject_GetAttrString(datetime_module, "datetime"); + if (datetime_class == NULL) + RETURN_ERROR; + if (unsuccessful(SQLAllocEnv(&Env))) { Index: dbi.def =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/dbi.def,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.2 diff -C2 -d -r1.1.4.1 -r1.1.4.2 *** dbi.def 29 Aug 2008 04:59:26 -0000 1.1.4.1 --- dbi.def 16 Sep 2008 01:01:17 -0000 1.1.4.2 *************** *** 1,12 **** EXPORTS dbiIsRaw - dbiIsDate dbiValue - dbiMakeDate dbiMakeRaw - dbiMakeRowId DbiString DbiRaw - DbiRowId DbiNumber DbiDate --- 1,8 ---- Index: dbi.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/dbi.cpp,v retrieving revision 1.10.2.2 retrieving revision 1.10.2.3 diff -C2 -d -r1.10.2.2 -r1.10.2.3 *** dbi.cpp 6 Sep 2008 22:33:20 -0000 1.10.2.2 --- dbi.cpp 16 Sep 2008 01:01:16 -0000 1.10.2.3 *************** *** 15,25 **** #include "structmember.h" - /* Python 1.5.2 doesn't have PyObject_New - PyObject_NEW is not *quite* as safe, but seem to work fine - (as all win32all for 1.5.2 used it! */ - #ifndef PyObject_New - #define PyObject_New PyObject_NEW - #endif - #define DBI_EXPORT --- 15,18 ---- *************** *** 63,71 **** { Py_DECREF(((DbiContainer *) self)->objectOf); - #ifdef PyObject_Del /* see top of file for 1.5.2 comments */ PyObject_Del(self); - #else - PyMem_Free(self); - #endif } --- 56,60 ---- *************** *** 82,93 **** } - static PyObject *dateStr(PyObject *o) - { - time_t t; - if (!PyWinObject_Astime_t(dbiValue(o), &t)) - return NULL; - return PyString_FromStringAndSize(ctime(&t), 24); /* less \n */ - } - #define delg(a) dbiValue(a)->ob_type->tp_as_number --- 71,74 ---- *************** *** 96,220 **** return delg(a)->nb_add(dbiValue(a),b); } - static PyObject* dt_nb_subtract(PyObject* a, PyObject* b) - { - return delg(a)->nb_subtract(dbiValue(a),b); - } - static PyObject* dt_nb_int(PyObject* a) - { - return delg(a)->nb_int(dbiValue(a)); - } - static PyObject* dt_nb_long(PyObject* a) - { - return delg(a)->nb_long(dbiValue(a)); - } - static PyObject* dt_nb_float(PyObject* a) - { - return delg(a)->nb_float(dbiValue(a)); - } - - #if (PY_VERSION_HEX < 0x03000000) - static PyObject* dt_nb_oct(PyObject* a) - { - return delg(a)->nb_oct(dbiValue(a)); - } - static PyObject* dt_nb_hex(PyObject* a) - { - return delg(a)->nb_hex(dbiValue(a)); - } - #endif - static int dt_cmp(PyObject *a, PyObject *b) - { - return dbiValue(a)->ob_type->tp_compare(a,b); - } - static int dt_nb_coerce(PyObject **, PyObject **); - - PyNumberMethods dt_as_number = - { - dt_nb_add , /* nb_add */ - dt_nb_subtract , /* nb_subtract */ - 0, /* nb_multiply */ - #if (PY_VERSION_HEX < 0x03000000) - 0, /* nb_divide (removed in Python 3)*/ - #endif - 0, /* nb_remainder */ - 0, /* nb_divmod */ - 0, /* nb_power */ - 0, /* nb_negative */ - 0, /* nb_positive */ - 0, /* nb_absolute */ - 0, /* nb_nonzero */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - 0, /* nb_and */ - 0, /* nb_xor */ - 0, /* nb_or */ - #if (PY_VERSION_HEX < 0x03000000) - dt_nb_coerce, /* nb_coerce (removed in Python 3) */ - #endif - dt_nb_int , /* nb_int */ - dt_nb_long , /* nb_long */ - dt_nb_float , /* nb_float */ - #if (PY_VERSION_HEX < 0x03000000) - dt_nb_oct , /* nb_oct */ - dt_nb_hex /* nb_hex */ - #endif - }; - - static PyTypeObject DbiDate_Type = - { - PYWIN_OBJECT_HEAD - "DbiDate", /*tp_name */ - sizeof(DbiContainer), /*tp_basicsize */ - 0, /*tp_itemsize */ - dbiDealloc, /*tp_dealloc */ - 0, /*tp_print */ - 0, /*tp_getattr */ - 0, /*tp_setattr */ - dt_cmp, /*tp_compare */ - 0, /*tp_repr */ - &dt_as_number, /**tp_as_number */ - 0, /**tp_as_sequence */ - 0, /**tp_as_mapping */ - 0, /*tp_hash */ - 0, /*tp_call */ - dateStr, /*tp_str */ - PyObject_GenericGetAttr, /* tp_getattro dbiGetAttr */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - noMethods, /* tp_methods */ - DbiContainer_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - static int dt_nb_coerce(PyObject **pv, PyObject **pw) - { - if (PyNumber_Check(*pw)) - { - DbiContainer *dbt = PyObject_New(DbiContainer, &DbiDate_Type); - dbt->objectOf = PyNumber_Int(*pw); - Py_INCREF(*pv); - *pw = (PyObject *)dbt; - return 0; - } - return 1; /* Can't do it */ - } static PyTypeObject DbiRaw_Type = --- 77,81 ---- *************** *** 260,310 **** }; - static PyTypeObject DbiRowId_Type = - { - PYWIN_OBJECT_HEAD - "DbiRowId", /*tp_name */ - sizeof(DbiContainer), /*tp_basicsize */ - 0, /*tp_itemsize */ - dbiDealloc, /*tp_dealloc */ - 0, /*tp_print */ - 0, /*tp_getattr */ - 0, /*tp_setattr */ - 0, /*tp_compare */ - 0, /*tp_repr */ - 0, /**tp_as_number */ - 0, /**tp_as_sequence */ - 0, /**tp_as_mapping */ - 0, /*tp_hash */ - 0, /*tp_call */ - dbiRawStr, /*tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - noMethods, /* tp_methods */ - DbiContainer_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - }; - - static PyObject *makeDate(PyObject *self, PyObject *args) - { - return makeDbiTypeTP(args, &DbiDate_Type); - } - static PyObject *makeRaw(PyObject *self, PyObject *args) { --- 121,124 ---- *************** *** 312,320 **** } - static PyObject *makeRowId(PyObject *self, PyObject *args) - { - return makeDbiTypeTP(args, &DbiRowId_Type); - } - static PyObject *makeDbiType(PyObject *o, PyTypeObject *ty) { --- 126,129 ---- *************** *** 324,332 **** } - PyObject *dbiMakeDate(PyObject *contents) - { - return makeDbiType(contents, &DbiDate_Type); - } - PyObject *dbiMakeRaw(PyObject *contents) { --- 133,136 ---- *************** *** 334,348 **** } - PyObject *dbiMakeRowId(PyObject *contents) - { - return makeDbiType(contents, &DbiRowId_Type); - } - - - static PyMethodDef globalMethods[] = { ! { "dbDate", makeDate, 1} , ! { "dbiDate", makeDate, 1} , { "dbRaw", makeRaw, 1} , { "dbiRaw", makeRaw, 1} , --- 138,145 ---- } static PyMethodDef globalMethods[] = { ! // { "dbDate", makeDate, 1} , ! // { "dbiDate", makeDate, 1} , { "dbRaw", makeRaw, 1} , { "dbiRaw", makeRaw, 1} , *************** *** 382,388 **** RETURN_ERROR; ! if (PyType_Ready(&DbiDate_Type) == -1 ! ||PyType_Ready(&DbiRaw_Type) == -1 ! ||PyType_Ready(&DbiRowId_Type) == -1) RETURN_ERROR; --- 179,183 ---- RETURN_ERROR; ! if (PyType_Ready(&DbiRaw_Type) == -1) RETURN_ERROR; *************** *** 454,469 **** } - int dbiIsDate(const PyObject *o) - { - return o->ob_type == &DbiDate_Type; - } - int dbiIsRaw(const PyObject *o) { return o->ob_type == &DbiRaw_Type; } - - int dbiIsRowId(const PyObject *o) - { - return o->ob_type == &DbiRowId_Type; - } --- 249,254 ---- |
From: Roger U. <ru...@us...> - 2008-09-16 00:47:57
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23617 Modified Files: test_odbc.py Log Message: Fix create table sql and date test Index: test_odbc.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_odbc.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_odbc.py 24 May 2007 05:38:35 -0000 1.7 --- test_odbc.py 16 Sep 2008 00:48:07 -0000 1.8 *************** *** 58,62 **** bitfield bit, intfield integer, floatfield float, ! datefield date, )"""),-1) --- 58,62 ---- bitfield bit, intfield integer, floatfield float, ! datefield date )"""),-1) *************** *** 139,143 **** ): d = datetime.datetime(*v) ! self._test_val('datefield', 'd') def test_set_nonzero_length(self): --- 139,143 ---- ): d = datetime.datetime(*v) ! self._test_val('datefield', d) def test_set_nonzero_length(self): |
From: Roger U. <ru...@us...> - 2008-09-15 07:46:28
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1747 Modified Files: Tag: py3k odbc.cpp Log Message: Bind long with SQL_C_LONG if it fits in 32 bits Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.3 retrieving revision 1.20.2.4 diff -C2 -d -r1.20.2.3 -r1.20.2.4 *** odbc.cpp 14 Sep 2008 15:53:44 -0000 1.20.2.3 --- odbc.cpp 15 Sep 2008 07:46:37 -0000 1.20.2.4 *************** *** 688,696 **** - static void OutOfMemory() - { - PyErr_SetString(odbcError, "out of memory"); - } - static SQLLEN NTS = SQL_NTS; --- 688,691 ---- *************** *** 707,711 **** else { ! OutOfMemory(); } return ib; --- 702,706 ---- else { ! PyErr_NoMemory(); } return ib; *************** *** 743,764 **** } ! static int ibindLong(cursorObject*cur,int column, PyObject *item) { ! int len = sizeof(long long); ! long long val = PyLong_AsLongLong(item); ! if (val == -1 && PyErr_Occurred()) ! return 0; ! InputBinding *ib = initInputBinding(cur, len); ! if (!ib) ! return 0; ! ! memcpy(ib->bind_area, &val, len); if (unsuccessful(SQLBindParameter( cur->hstmt, column, ! SQL_PARAM_INPUT, ! SQL_C_SBIGINT, ! SQL_BIGINT, len, 0, --- 738,777 ---- } ! static int ibindLong(cursorObject*cur,int column, PyObject *item) { ! /* This will always be called in Py3k, so differentiate between an int ! that fits in a long, and one that requires a 64=bit datatype. */ ! int len; ! InputBinding *ib; ! SQLSMALLINT ParamType=SQL_PARAM_INPUT, CType, SqlType; ! long longval = PyLong_AsLong(item); ! if (longval != -1 || !PyErr_Occurred()){ ! CType = SQL_C_LONG; ! SqlType = SQL_INTEGER; ! len = sizeof(long); ! ib = initInputBinding(cur, len); ! if (!ib) ! return 0; ! memcpy(ib->bind_area, &longval, len); ! } ! else{ ! long long longlongval = PyLong_AsLongLong(item); ! if (longlongval == -1 && PyErr_Occurred()) ! return 0; ! CType = SQL_C_SBIGINT; ! SqlType = SQL_BIGINT; ! len = sizeof(long long); ! ib = initInputBinding(cur, len); ! if (!ib) ! return 0; ! memcpy(ib->bind_area, &longlongval, len); ! } if (unsuccessful(SQLBindParameter( cur->hstmt, column, ! ParamType, ! CType, ! SqlType, len, 0, *************** *** 1374,1379 **** cur->description = NULL; PyWinObject_FreeTCHAR(sql); ! OutOfMemory(); ! return NULL; } --- 1387,1391 ---- cur->description = NULL; PyWinObject_FreeTCHAR(sql); ! return PyErr_NoMemory(); } |
From: Roger U. <ru...@us...> - 2008-09-15 05:05:01
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1697 Modified Files: Tag: py3k AutoIndent.py Log Message: Uncomment guess_indent Index: AutoIndent.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle/AutoIndent.py,v retrieving revision 1.3.2.3 retrieving revision 1.3.2.4 diff -C2 -d -r1.3.2.3 -r1.3.2.4 *** AutoIndent.py 11 Sep 2008 07:51:22 -0000 1.3.2.3 --- AutoIndent.py 15 Sep 2008 05:05:11 -0000 1.3.2.4 *************** *** 102,106 **** def set_indentation_params(self, ispythonsource, guess=1): if guess and ispythonsource: ! i = 4 ## self.guess_indent() if 2 <= i <= 8: self.indentwidth = i --- 102,106 ---- def set_indentation_params(self, ispythonsource, guess=1): if guess and ispythonsource: ! i = self.guess_indent() if 2 <= i <= 8: self.indentwidth = i |
From: Roger U. <ru...@us...> - 2008-09-14 15:53:34
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11082 Modified Files: Tag: py3k odbc.cpp Log Message: Some fixes for 64-bit Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.2 retrieving revision 1.20.2.3 diff -C2 -d -r1.20.2.2 -r1.20.2.3 *** odbc.cpp 6 Sep 2008 22:33:20 -0000 1.20.2.2 --- odbc.cpp 14 Sep 2008 15:53:44 -0000 1.20.2.3 *************** *** 31,47 **** #endif ! #ifdef _WIN64 ! # define mktime _mktime32 ! #endif ! ! /* Python 1.5.2 doesn't have PyObject_New ! PyObject_NEW is not *quite* as safe, but seem to work fine ! (as all win32all for 1.5.2 used it! */ ! #ifndef PyObject_New ! #define PyObject_New PyObject_NEW ! #endif ! #ifndef PyObject_Del ! #define PyObject_Del PyMem_DEL ! #endif #include "dbi.h" /*$ This is a hack */ --- 31,37 ---- #endif ! // #ifdef _WIN64 ! // # define mktime _mktime32 ! // #endif #include "dbi.h" /*$ This is a hack */ *************** *** 629,633 **** gt.tm_min = dt->minute; gt.tm_sec = dt->second; ! return dbiMakeDate(PyInt_FromLong(mktime(>))); } --- 619,623 ---- gt.tm_min = dt->minute; gt.tm_sec = dt->second; ! return dbiMakeDate(PyLong_FromLongLong(mktime(>))); } |
From: Roger U. <ru...@us...> - 2008-09-14 07:02:04
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30796 Modified Files: Tag: py3k _win32sysloader.cpp Log Message: Return module from init function - ??? Why did this succeed before ??? Index: _win32sysloader.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/_win32sysloader.cpp,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.2 diff -C2 -d -r1.1.4.1 -r1.1.4.2 *** _win32sysloader.cpp 29 Aug 2008 04:59:26 -0000 1.1.4.1 --- _win32sysloader.cpp 14 Sep 2008 07:02:11 -0000 1.1.4.2 *************** *** 76,87 **** }; ! extern "C" __declspec(dllexport) void #if (PY_VERSION_HEX < 0x03000000) ! init_win32sysloader(void) { ! Py_InitModule("_win32sysloader", functions); } #else ! PyInit__win32sysloader(void) { static PyModuleDef _win32sysloader_def = { --- 76,87 ---- }; ! extern "C" __declspec(dllexport) #if (PY_VERSION_HEX < 0x03000000) ! void init_win32sysloader(void) { ! PyObject *module=Py_InitModule("_win32sysloader", functions); } #else ! PyObject *PyInit__win32sysloader(void) { static PyModuleDef _win32sysloader_def = { *************** *** 92,96 **** functions }; ! PyModule_Create(&_win32sysloader_def); } #endif --- 92,97 ---- functions }; ! PyObject *module=PyModule_Create(&_win32sysloader_def); ! return module; } #endif |
From: Roger U. <ru...@us...> - 2008-09-14 06:02:48
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7068 Modified Files: Tag: py3k AXScript.cpp Log Message: Convert module init for Py3k Index: AXScript.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/src/AXScript.cpp,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** AXScript.cpp 9 Feb 2001 07:35:53 -0000 1.3 --- AXScript.cpp 14 Sep 2008 06:02:56 -0000 1.3.4.1 *************** *** 141,154 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) void initaxscript() { char *modName = "axscript"; - PyObject *oModule; // Create the module and add the functions ! oModule = Py_InitModule(modName, axcom_methods); ! if (!oModule) /* Eeek - some serious error! */ ! return; ! PyObject *dict = PyModule_GetDict(oModule); ! if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. --- 141,175 ---- /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initaxscript(void) ! #else ! PyObject *PyInit_axscript(void) ! #endif { + PyObject *dict, *module; char *modName = "axscript"; // Create the module and add the functions ! #if (PY_VERSION_HEX < 0x03000000) ! #define RETURN_ERROR return; ! module = Py_InitModule(modName, axcom_methods); ! ! #else ! #define RETURN_ERROR return NULL; ! static PyModuleDef axscript_def = { ! PyModuleDef_HEAD_INIT, ! "axscript", ! "A module, encapsulating the ActiveX Scripting interfaces.", ! -1, ! axcom_methods ! }; ! module = PyModule_Create(&axscript_def); ! #endif ! ! if (!module) /* Eeek - some serious error! */ ! RETURN_ERROR; ! dict = PyModule_GetDict(module); ! if (!dict) /* Another serious error!*/ ! RETURN_ERROR; // Register all of our interfaces, gateways and IIDs. *************** *** 211,213 **** --- 232,238 ---- ADD_CONSTANT(INTERFACE_USES_SECURITY_MANAGER); // Object knows to use IInternetHostSecurityManager #endif + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } |
From: Roger U. <ru...@us...> - 2008-09-14 03:34:36
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axdebug/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12648 Modified Files: Tag: py3k AXDebug.cpp Log Message: Convert module init for Py3k Index: AXDebug.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/src/AXDebug.cpp,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** AXDebug.cpp 10 Mar 2003 01:01:40 -0000 1.4 --- AXDebug.cpp 14 Sep 2008 03:34:45 -0000 1.4.4.1 *************** *** 207,211 **** } /* List of module functions */ ! // @module axdebug|A module, encapsulating the ActiveX Debugging static struct PyMethodDef axdebug_methods[]= { --- 207,211 ---- } /* List of module functions */ ! // @module axdebug|A module, encapsulating the ActiveX Debugging interfaces static struct PyMethodDef axdebug_methods[]= { *************** *** 216,232 **** }; - static int AddConstant(PyObject *dict, const char *key, long value) - { - PyObject *oval = PyInt_FromLong(value); - if (!oval) - { - return 1; - } - int rc = PyDict_SetItemString(dict, (char*)key, oval); - Py_DECREF(oval); - return rc; - } - - #define ADD_CONSTANT(tok) AddConstant(dict, #tok, tok) // The list of interfaces and gateways we support. --- 216,219 ---- *************** *** 293,318 **** }; /* Module initialisation */ ! extern "C" __declspec(dllexport) void initaxdebug() { ! char *modName = "axdebug"; ! PyObject *oModule; ! // We need to be thread friendly! PyEval_InitThreads(); - // Create the module and add the functions - oModule = Py_InitModule(modName, axdebug_methods); - if (!oModule) /* Eeek - some serious error! */ - return; - PyObject *dict = PyModule_GetDict(oModule); - if (!dict) return; /* Another serious error!*/ ! // Add some symbolic constants to the module ! axdebug_Error = PyString_FromString("error"); if (axdebug_Error == NULL || PyDict_SetItemString(dict, "error", axdebug_Error) != 0) ! { ! PyErr_SetString(PyExc_MemoryError, "can't define error"); ! return; ! } // AX-Debugging interface registration --- 280,322 ---- }; + #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) RETURN_ERROR; /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initaxdebug(void) ! #else ! PyObject *PyInit_axdebug(void) ! #endif { ! PyObject *module, *dict; ! ! #if (PY_VERSION_HEX < 0x03000000) ! #define RETURN_ERROR return; ! module = Py_InitModule("axdebug", axdebug_methods); ! #else ! #define RETURN_ERROR return NULL; ! static PyModuleDef axdebug_def = { ! PyModuleDef_HEAD_INIT, ! "axdebug", ! "A module, encapsulating the ActiveX Debugging interfaces", ! -1, ! axdebug_methods ! }; ! module = PyModule_Create(&axdebug_def); ! #endif ! ! if (!module) ! RETURN_ERROR; ! dict = PyModule_GetDict(module); ! if (!dict) ! RETURN_ERROR; ! PyEval_InitThreads(); ! // Add some symbolic constants to the module ! axdebug_Error = PyErr_NewException("axdebug.error", NULL, NULL); if (axdebug_Error == NULL || PyDict_SetItemString(dict, "error", axdebug_Error) != 0) ! RETURN_ERROR; // AX-Debugging interface registration *************** *** 400,405 **** ADD_CONSTANT(TEXT_DOC_ATTR_READONLY); // @const axdebug|TEXT_DOC_ATTR_READONLY|Indicates that the document is read-only. ! ! // ADD_CONSTANT(); ! } --- 404,409 ---- ADD_CONSTANT(TEXT_DOC_ATTR_READONLY); // @const axdebug|TEXT_DOC_ATTR_READONLY|Indicates that the document is read-only. ! #if (PY_VERSION_HEX >= 0x03000000) ! return module; ! #endif } |
From: Roger U. <ru...@us...> - 2008-09-13 20:33:54
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6759 Modified Files: Tag: py3k test_pywintypes.py Log Message: Change IID tests for Py3k Index: test_pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_pywintypes.py,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** test_pywintypes.py 26 May 2004 08:29:20 -0000 1.3 --- test_pywintypes.py 13 Sep 2008 20:34:03 -0000 1.3.4.1 *************** *** 25,31 **** s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) ! iid2 = pywintypes.IID(buffer(iid), True) self.assertEquals(iid, iid2) ! self.assertRaises(ValueError, pywintypes.IID, '00', True) # too short self.assertRaises(TypeError, pywintypes.IID, 0, True) # no buffer --- 25,31 ---- s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) ! iid2 = pywintypes.IID(bytes(iid), True) self.assertEquals(iid, iid2) ! self.assertRaises(ValueError, pywintypes.IID, b'00', True) # too short self.assertRaises(TypeError, pywintypes.IID, 0, True) # no buffer |
From: Roger U. <ru...@us...> - 2008-09-13 17:42:23
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv306 Modified Files: Tag: py3k AXControl.cpp Log Message: Convert module init for Py3k Index: AXControl.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axcontrol/src/AXControl.cpp,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** AXControl.cpp 15 Oct 2007 05:20:44 -0000 1.8 --- AXControl.cpp 13 Sep 2008 17:42:33 -0000 1.8.2.1 *************** *** 335,351 **** }; - static int AddConstant(PyObject *dict, const char *key, long value) - { - PyObject *oval = PyInt_FromLong(value); - if (!oval) - { - return 1; - } - int rc = PyDict_SetItemString(dict, (char*)key, oval); - Py_DECREF(oval); - return rc; - } ! #define ADD_CONSTANT(tok) AddConstant(dict, #tok, tok) static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = --- 335,340 ---- }; ! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) RETURN_ERROR; static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = *************** *** 367,380 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) void initaxcontrol() { ! char *modName = "axcontrol"; ! PyObject *oModule; ! // Create the module and add the functions ! oModule = Py_InitModule(modName, axcontrol_methods); ! if (!oModule) /* Eeek - some serious error! */ ! return; ! PyObject *dict = PyModule_GetDict(oModule); ! if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. --- 356,388 ---- /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initaxcontrol(void) ! #else ! PyObject *PyInit_axcontrol(void) ! #endif { ! PyObject *dict, *module; ! ! #if (PY_VERSION_HEX < 0x03000000) ! #define RETURN_ERROR return; ! module = Py_InitModule("axcontrol", axcontrol_methods); ! #else ! #define RETURN_ERROR return NULL; ! static PyModuleDef axcontrol_def = { ! PyModuleDef_HEAD_INIT, ! "axcontrol", ! "A module, encapsulating the ActiveX Control interfaces.", ! -1, ! axcontrol_methods ! }; ! module = PyModule_Create(&axcontrol_def); ! #endif ! ! if (!module) ! RETURN_ERROR; ! dict = PyModule_GetDict(module); ! if (!dict) ! RETURN_ERROR; // Register all of our interfaces, gateways and IIDs. *************** *** 406,408 **** --- 414,420 ---- ADD_CONSTANT(EMBDHLP_DELAYCREATE); // @const axcontrol|EMBDHLP_DELAYCREATE| ADD_CONSTANT(OLECREATE_LEAVERUNNING); // @const axcontrol|OLECREATE_LEAVERUNNING| + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } |
From: Roger U. <ru...@us...> - 2008-09-13 16:21:20
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30863 Modified Files: Tag: py3k PyIFilter.cpp Log Message: Allow to build with UNICODE defined Index: PyIFilter.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src/PyIFilter.cpp,v retrieving revision 1.6.4.1 retrieving revision 1.6.4.2 diff -C2 -d -r1.6.4.1 -r1.6.4.2 *** PyIFilter.cpp 29 Aug 2008 08:32:47 -0000 1.6.4.1 --- PyIFilter.cpp 13 Sep 2008 16:21:29 -0000 1.6.4.2 *************** *** 354,358 **** // Tell pywintypes that IFilter error messages can be extracted from // query.dll ! HMODULE hmod = GetModuleHandle("query.dll"); if (hmod) // According to FiltErr.h, "Codes 0x1700-0x172F are reserved for FILTER" --- 354,358 ---- // Tell pywintypes that IFilter error messages can be extracted from // query.dll ! HMODULE hmod = GetModuleHandle(_T("query.dll")); if (hmod) // According to FiltErr.h, "Codes 0x1700-0x172F are reserved for FILTER" |
From: Roger U. <ru...@us...> - 2008-09-13 16:14:15
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28021 Modified Files: Tag: py3k ds_record.py ds_test.py Log Message: Put recorded file in temp directory Index: ds_record.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_record.py,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.2 diff -C2 -d -r1.1.4.1 -r1.1.4.2 *** ds_record.py 7 Sep 2008 02:22:03 -0000 1.1.4.1 --- ds_record.py 13 Sep 2008 16:14:24 -0000 1.1.4.2 *************** *** 1,5 **** import pywintypes import struct ! import win32event import win32com.directsound.directsound as ds --- 1,6 ---- import pywintypes import struct ! import win32event, win32api ! import os import win32com.directsound.directsound as ds *************** *** 38,42 **** data = buffer.Update(0, 352800) ! f = open('recording.wav', 'wb') f.write(wav_header_pack(sdesc.lpwfxFormat, 352800)) f.write(data) --- 39,44 ---- data = buffer.Update(0, 352800) ! fname=os.path.join(win32api.GetTempPath(), 'test_directsound_record.wav') ! f = open(fname, 'wb') f.write(wav_header_pack(sdesc.lpwfxFormat, 352800)) f.write(data) Index: ds_test.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/test/ds_test.py,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -C2 -d -r1.4.4.1 -r1.4.4.2 *** ds_test.py 7 Sep 2008 02:22:03 -0000 1.4.4.1 --- ds_test.py 13 Sep 2008 16:14:24 -0000 1.4.4.2 *************** *** 4,8 **** import os import pywintypes ! import win32event import win32com.directsound.directsound as ds # next two lines are for for debugging: --- 4,9 ---- import os import pywintypes ! import win32event, win32api ! import os import win32com.directsound.directsound as ds # next two lines are for for debugging: *************** *** 14,18 **** def wav_header_unpack(data): - print (struct.unpack('<4sl4s4slhhllhh4sl', data)) (riff, riffsize, wave, fmt, fmtsize, format, nchannels, samplespersecond, datarate, blockalign, bitspersample, data, datalength) \ --- 15,18 ---- *************** *** 330,335 **** data = buffer.Update(0, 352800) ! ! f = open('recording.wav', 'wb') f.write(wav_header_pack(sdesc.lpwfxFormat, 352800)) f.write(data) --- 330,335 ---- data = buffer.Update(0, 352800) ! fname=os.path.join(win32api.GetTempPath(), 'test_directsound_record.wav') ! f = open(fname, 'wb') f.write(wav_header_pack(sdesc.lpwfxFormat, 352800)) f.write(data) |
From: Roger U. <ru...@us...> - 2008-09-13 16:09:42
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26024 Modified Files: Tag: py3k directsound.cpp Log Message: Allow to build with UNICODE defined Index: directsound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/directsound.cpp,v retrieving revision 1.8.4.2 retrieving revision 1.8.4.3 diff -C2 -d -r1.8.4.2 -r1.8.4.3 *** directsound.cpp 7 Sep 2008 02:21:10 -0000 1.8.4.2 --- directsound.cpp 13 Sep 2008 16:09:51 -0000 1.8.4.3 *************** *** 68,72 **** } ! BOOL CALLBACK dsEnumCallback(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOID context) { PyObject *list = (PyObject*)context; --- 68,72 ---- } ! BOOL CALLBACK dsEnumCallback(LPGUID guid, LPCTSTR desc, LPCTSTR module, LPVOID context) { PyObject *list = (PyObject*)context; *************** *** 93,100 **** return FALSE; ! if (PyTuple_SetItem(item, 1, desc ? PyString_FromString(desc) : PyString_FromString(""))) return FALSE; ! if (PyTuple_SetItem(item, 2, module ? PyString_FromString(module) : PyString_FromString(""))) return FALSE; --- 93,100 ---- return FALSE; ! if (PyTuple_SetItem(item, 1, PyWinObject_FromTCHAR(desc))) return FALSE; ! if (PyTuple_SetItem(item, 2, PyWinObject_FromTCHAR(module))) return FALSE; |
From: Roger U. <ru...@us...> - 2008-09-13 15:48:22
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17590 Modified Files: Tag: py3k PyIExtractIcon.cpp PyIShellLink.cpp shell.cpp Log Message: Allow to build with UNICODE defined Index: PyIShellLink.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellLink.cpp,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -C2 -d -r1.9 -r1.9.2.1 *** PyIShellLink.cpp 3 Jun 2007 14:53:07 -0000 1.9 --- PyIShellLink.cpp 13 Sep 2008 15:48:31 -0000 1.9.2.1 *************** *** 61,67 **** return OleSetOleError(hr); } ! PyObject *obFD = PyObject_FromWIN32_FIND_DATAA(&fd); ! PyObject *obFile = PyWinObject_FromTCHAR(pszFile); ! PyObject *ret = Py_BuildValue("NN", obFile, obFD); free(pszFile); return ret; --- 61,67 ---- return OleSetOleError(hr); } ! PyObject *ret = Py_BuildValue("NN", ! PyWinObject_FromTCHAR(pszFile), ! PyObject_FromWIN32_FIND_DATA(&fd)); free(pszFile); return ret; Index: PyIExtractIcon.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIExtractIcon.cpp,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** PyIExtractIcon.cpp 26 Jul 2008 02:31:48 -0000 1.5 --- PyIExtractIcon.cpp 13 Sep 2008 15:48:31 -0000 1.5.2.1 *************** *** 114,118 **** PY_GATEWAY_METHOD; PyObject *obpszFile; ! obpszFile = PyString_FromString((LPTSTR)pszFile); PyObject *result; HRESULT hr=InvokeViaPolicy("Extract", &result, "Oii", obpszFile, nIconIndex, nIconSize); --- 114,118 ---- PY_GATEWAY_METHOD; PyObject *obpszFile; ! obpszFile = PyWinObject_FromTCHAR(pszFile); PyObject *result; HRESULT hr=InvokeViaPolicy("Extract", &result, "Oii", obpszFile, nIconIndex, nIconSize); *************** *** 156,163 **** else { if (PyArg_ParseTuple(result, "Oii", &obFileName, piIndex, pflags)) { ! char *filename; ! if (PyWinObject_AsString(obFileName, &filename)) { ! strncpy(szIconFile, filename, cchMax); ! PyWinObject_FreeString(filename); } } --- 156,163 ---- else { if (PyArg_ParseTuple(result, "Oii", &obFileName, piIndex, pflags)) { ! TCHAR *filename; ! if (PyWinObject_AsTCHAR(obFileName, &filename)) { ! _tcsncpy(szIconFile, filename, cchMax); ! PyWinObject_FreeTCHAR(filename); } } Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.68.2.1 retrieving revision 1.68.2.2 diff -C2 -d -r1.68.2.1 -r1.68.2.2 *** shell.cpp 29 Aug 2008 08:33:13 -0000 1.68.2.1 --- shell.cpp 13 Sep 2008 15:48:31 -0000 1.68.2.2 *************** *** 1769,1773 **** return PyErr_NoMemory(); nchars = ::DragQueryFile(hglobal, index, sz, nchars); ! PyObject *ret = PyString_FromStringAndSize(sz, nchars); free(sz); return ret; --- 1769,1773 ---- return PyErr_NoMemory(); nchars = ::DragQueryFile(hglobal, index, sz, nchars); ! PyObject *ret = PyWinObject_FromTCHAR(sz, nchars); free(sz); return ret; *************** *** 1968,1972 **** --- 1968,1976 ---- // on what other attributes exist. // @pyparm bool|make_unicode|False|If true, a FILEDESCRIPTORW object is created + #ifdef UNICODE + int make_unicode = TRUE; + #else int make_unicode = FALSE; + #endif if (!PyArg_ParseTuple(args, "O|i", &ob, &make_unicode)) return NULL; |
From: Roger U. <ru...@us...> - 2008-09-13 14:40:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22758 Modified Files: Tag: py3k testShell.py Log Message: Pass PIDL's as byte strings Index: testShell.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testShell.py,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -C2 -d -r1.10 -r1.10.4.1 *** testShell.py 22 Sep 2006 05:05:51 -0000 1.10 --- testShell.py 13 Sep 2008 14:40:54 -0000 1.10.4.1 *************** *** 31,35 **** if num == 0: # This isn't a fatal error, but is unlikely. ! print "Could not find any links on your desktop, which is unusual" def testShellFolder(self): --- 31,35 ---- if num == 0: # This isn't a fatal error, but is unlikely. ! print ("Could not find any links on your desktop, which is unusual") def testShellFolder(self): *************** *** 68,87 **** def testPIDL(self): # A PIDL of "\1" is: cb pidl cb ! expect = "\03\00" "\1" "\0\0" ! self.assertEqual(shell.PIDLAsString(["\1"]), expect) ! self._rtPIDL(["\0"]) ! self._rtPIDL(["\1", "\2", "\3"]) ! self._rtPIDL(["\0" * 2048] * 2048) # PIDL must be a list self.assertRaises(TypeError, shell.PIDLAsString, "foo") def testCIDA(self): ! self._rtCIDA(["\0"], [ ["\0"] ]) ! self._rtCIDA(["\1"], [ ["\2"] ]) ! self._rtCIDA(["\0"], [ ["\0"], ["\1"], ["\2"] ]) def testBadShortPIDL(self): # A too-short child element: cb pidl cb ! pidl = "\01\00" "\1" self.assertRaises(ValueError, shell.StringAsPIDL, pidl) --- 68,87 ---- def testPIDL(self): # A PIDL of "\1" is: cb pidl cb ! expect = b"\03\00" b"\1" b"\0\0" ! self.assertEqual(shell.PIDLAsString([b"\1"]), expect) ! self._rtPIDL([b"\0"]) ! self._rtPIDL([b"\1", b"\2", b"\3"]) ! self._rtPIDL([b"\0" * 2048] * 2048) # PIDL must be a list self.assertRaises(TypeError, shell.PIDLAsString, "foo") def testCIDA(self): ! self._rtCIDA([b"\0"], [ [b"\0"] ]) ! self._rtCIDA([b"\1"], [ [b"\2"] ]) ! self._rtCIDA([b"\0"], [ [b"\0"], [b"\1"], [b"\2"] ]) def testBadShortPIDL(self): # A too-short child element: cb pidl cb ! pidl = b"\01\00" b"\1" self.assertRaises(ValueError, shell.StringAsPIDL, pidl) *************** *** 91,96 **** class FILEGROUPDESCRIPTORTester(win32com.test.util.TestCase): def _testRT(self, fd): ! fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd]) ! fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string)[0] fd = fd.copy() --- 91,96 ---- class FILEGROUPDESCRIPTORTester(win32com.test.util.TestCase): def _testRT(self, fd): ! fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd], 1) ! fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string, 1)[0] fd = fd.copy() *************** *** 98,104 **** # The returned objects *always* have dwFlags and cFileName. ! if not fd.has_key('dwFlags'): del fd2['dwFlags'] ! if not fd.has_key('cFileName'): self.assertEqual(fd2['cFileName'], '') del fd2['cFileName'] --- 98,104 ---- # The returned objects *always* have dwFlags and cFileName. ! if 'dwFlags' not in fd: del fd2['dwFlags'] ! if 'cFileName' not in fd: self.assertEqual(fd2['cFileName'], '') del fd2['cFileName'] *************** *** 130,134 **** ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxint + 1) self._testRT(d) --- 130,134 ---- ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxsize + 1) self._testRT(d) *************** *** 138,142 **** # no kw-args to dict in 2.2 - not worth converting! return ! d = [dict(cFileName=u"foo.txt", sizel=(1,2), pointl=(3,4), --- 138,142 ---- # no kw-args to dict in 2.2 - not worth converting! return ! d = [dict(cFileName="foo.txt", sizel=(1,2), pointl=(3,4), *************** *** 145,150 **** ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxint + 1), ! dict(cFileName=u"foo2.txt", sizel=(1,2), pointl=(3,4), --- 145,150 ---- ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxsize + 1), ! dict(cFileName="foo2.txt", sizel=(1,2), pointl=(3,4), *************** *** 153,158 **** ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxint + 1), ! dict(cFileName=u"foo\xa9.txt", sizel=(1,2), pointl=(3,4), --- 153,158 ---- ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxsize + 1), ! dict(cFileName="foo\xa9.txt", sizel=(1,2), pointl=(3,4), *************** *** 161,165 **** ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxint + 1), ] s = shell.FILEGROUPDESCRIPTORAsString(d, 1) --- 161,165 ---- ftLastAccessTime=pythoncom.MakeTime(11), ftLastWriteTime=pythoncom.MakeTime(12), ! nFileSize=sys.maxsize + 1), ] s = shell.FILEGROUPDESCRIPTORAsString(d, 1) *************** *** 175,180 **** self.src_name = os.path.join(tempfile.gettempdir(), "pywin32_testshell") self.dest_name = os.path.join(tempfile.gettempdir(), "pywin32_testshell_dest") ! self.test_data = "Hello from\0Python" ! f=file(self.src_name, "wb") f.write(self.test_data) f.close() --- 175,180 ---- self.src_name = os.path.join(tempfile.gettempdir(), "pywin32_testshell") self.dest_name = os.path.join(tempfile.gettempdir(), "pywin32_testshell_dest") ! self.test_data = b"Hello from\0Python" ! f=open(self.src_name, "wb") f.write(self.test_data) f.close() |
From: Roger U. <ru...@us...> - 2008-09-13 13:31:19
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27646 Modified Files: Tag: py3k oleargs.cpp Log Message: Return unicode from OleSetTypeError Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.41.2.2 retrieving revision 1.41.2.3 diff -C2 -d -r1.41.2.2 -r1.41.2.3 *** oleargs.cpp 13 Sep 2008 04:26:18 -0000 1.41.2.2 --- oleargs.cpp 13 Sep 2008 13:31:28 -0000 1.41.2.3 *************** *** 17,32 **** // A little helper just for this file ! static PyObject* OleSetTypeError(char *msg) ! { ! PyErr_SetString(PyExc_TypeError, msg); ! return NULL; ! } ! ! #ifdef UNICODE ! // In a Unicode environment, we provide a helper that ! // converts the argument to a string before raising the error. ! static PyObject* OleSetTypeErrorW(TCHAR *msg) { ! PyObject *obMsg = PyString_FromUnicode(msg); if (obMsg) { PyErr_SetObject(PyExc_TypeError, obMsg); --- 17,23 ---- // A little helper just for this file ! static PyObject* OleSetTypeError(TCHAR *msg) { ! PyObject *obMsg = PyWinObject_FromTCHAR(msg); if (obMsg) { PyErr_SetObject(PyExc_TypeError, obMsg); *************** *** 35,42 **** return NULL; } - #define OleSetTypeErrorT OleSetTypeErrorW - #else - #define OleSetTypeErrorT OleSetTypeError - #endif /////////////////////////////////////////////////////////// --- 26,29 ---- *************** *** 229,233 **** /* ### note: we shouldn't see this, it is illegal in a VARIANT */ if (V_ISVECTOR(var)) { ! return OleSetTypeError("Cant convert vectors!"); } --- 216,220 ---- /* ### note: we shouldn't see this, it is illegal in a VARIANT */ if (V_ISVECTOR(var)) { ! return OleSetTypeError(_T("Cant convert vectors!")); } *************** *** 267,271 **** TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeErrorT(buf); break; } --- 254,258 ---- TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeError(buf); break; } *************** *** 287,291 **** TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeErrorT(buf); break; } --- 274,278 ---- TCHAR buf[200]; wsprintf(buf, _T("Error converting integer variant (%08lx)"), hr); ! OleSetTypeError(buf); break; } *************** *** 305,309 **** TCHAR buf[200]; wsprintf(buf, _T("Error converting floating point variant (%08lx)"), hr); ! OleSetTypeErrorT(buf); break; } --- 292,296 ---- TCHAR buf[200]; wsprintf(buf, _T("Error converting floating point variant (%08lx)"), hr); ! OleSetTypeError(buf); break; } *************** *** 368,372 **** TCHAR buf[200]; wsprintf(buf, _T("The Variant type (0x%x) is not supported, and it can not be converted to a string"), V_VT(var)); ! OleSetTypeErrorT(buf); break; } --- 355,359 ---- TCHAR buf[200]; wsprintf(buf, _T("The Variant type (0x%x) is not supported, and it can not be converted to a string"), V_VT(var)); ! OleSetTypeError(buf); break; } *************** *** 390,394 **** LONG numElements = pBounds[dimNo-1].cElements; if ((LONG)PySequence_Length(obj)!=numElements) { ! OleSetTypeError("All dimensions must be a sequence of the same size"); return FALSE; } --- 377,381 ---- LONG numElements = pBounds[dimNo-1].cElements; if ((LONG)PySequence_Length(obj)!=numElements) { ! OleSetTypeError(_T("All dimensions must be a sequence of the same size")); return FALSE; } *************** *** 403,407 **** if (bufSize != numElements) { ! OleSetTypeError("Internal error - the buffer length is not the sequence length!"); return FALSE; } --- 390,394 ---- if (bufSize != numElements) { ! OleSetTypeError(_T("Internal error - the buffer length is not the sequence length!")); return FALSE; } *************** *** 434,438 **** // Complex conversion. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError("Internal error - unexpected argument - only simple VARIANTTYPE expected"); ok = FALSE; } else { --- 421,425 ---- // Complex conversion. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError(_T("Internal error - unexpected argument - only simple VARIANTTYPE expected")); ok = FALSE; } else { *************** *** 595,599 **** if (cDims==0) { ! OleSetTypeError("Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object."); return FALSE; } --- 582,586 ---- if (cDims==0) { ! OleSetTypeError(_T("Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object.")); return FALSE; } *************** *** 802,806 **** TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type 0x%x is not supported for SAFEARRAYS"), vt); ! OleSetTypeErrorT(buf); } } --- 789,793 ---- TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type 0x%x is not supported for SAFEARRAYS"), vt); ! OleSetTypeError(buf); } } *************** *** 891,895 **** // Our caller must has resolved all byref and array references. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError("Internal error - unexpected argument - only simple VARIANTTYPE expected"); return FALSE; } --- 878,882 ---- // Our caller must has resolved all byref and array references. if (vt & VT_ARRAY || vt & VT_BYREF) { ! OleSetTypeError(_T("Internal error - unexpected argument - only simple VARIANTTYPE expected")); return FALSE; } *************** *** 1051,1055 **** } if (m_reqdType & VT_VECTOR) { // we have been asked for an array. ! OleSetTypeError("Sorry - cant support VT_VECTOR arguments"); return FALSE; } --- 1038,1042 ---- } if (m_reqdType & VT_VECTOR) { // we have been asked for an array. ! OleSetTypeError(_T("Sorry - cant support VT_VECTOR arguments")); return FALSE; } *************** *** 1338,1342 **** TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type is unknown (0x%08lx)"), m_reqdType); ! OleSetTypeErrorT(buf); rc = FALSE; break; --- 1325,1329 ---- TCHAR buf[200]; wsprintf(buf, _T("The VARIANT type is unknown (0x%08lx)"), m_reqdType); ! OleSetTypeError(buf); rc = FALSE; break; |
From: Roger U. <ru...@us...> - 2008-09-13 12:27:32
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1953 Modified Files: Tag: py3k testStreams.py Log Message: Use bytes for test data Index: testStreams.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testStreams.py,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** testStreams.py 31 Aug 2007 02:08:14 -0000 1.6 --- testStreams.py 13 Sep 2008 12:27:42 -0000 1.6.2.1 *************** *** 10,14 **** _com_interfaces_ = [ pythoncom.IID_IPersistStreamInit ] def __init__(self): ! self.data = "abcdefg" self.dirty = 1 def GetClassID(self): --- 10,14 ---- _com_interfaces_ = [ pythoncom.IID_IPersistStreamInit ] def __init__(self): ! self.data = b"abcdefg" self.dirty = 1 def GetClassID(self): *************** *** 55,59 **** self.index = len(self.data)+dist else: ! raise ValueError, 'Unknown Seek type: ' +str(origin) if self.index < 0: self.index = 0 --- 55,59 ---- self.index = len(self.data)+dist else: ! raise ValueError('Unknown Seek type: ' +str(origin)) if self.index < 0: self.index = 0 *************** *** 67,71 **** """ def Read(self, amount): ! return 'x'*(amount+1) class StreamTest(win32com.test.util.TestCase): --- 67,71 ---- """ def Read(self, amount): ! return b'x'*(amount+1) class StreamTest(win32com.test.util.TestCase): *************** *** 81,85 **** def testit(self): ! mydata = 'abcdefghijklmnopqrstuvwxyz' # First test the objects just as Python objects... --- 81,85 ---- def testit(self): ! mydata = b'abcdefghijklmnopqrstuvwxyz' # First test the objects just as Python objects... *************** *** 101,105 **** self._readWrite(mydata, s2, s2) ! self._readWrite("string with\0a NULL", s2, s2) # reset the stream s.Write(mydata) --- 101,105 ---- self._readWrite(mydata, s2, s2) ! self._readWrite(b"string with\0a NULL", s2, s2) # reset the stream s.Write(mydata) |
From: Roger U. <ru...@us...> - 2008-09-13 04:26:10
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2919 Modified Files: Tag: py3k ErrorUtils.cpp PyGatewayBase.cpp PyIUnknown.cpp PyRecord.cpp PyStorage.cpp PythonCOM.cpp dllmain.cpp oleargs.cpp Log Message: Allow to build with UNICODE defined More changes for Py3k Index: PyGatewayBase.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyGatewayBase.cpp,v retrieving revision 1.17.2.1 retrieving revision 1.17.2.2 diff -C2 -d -r1.17.2.1 -r1.17.2.2 *** PyGatewayBase.cpp 29 Aug 2008 08:27:37 -0000 1.17.2.1 --- PyGatewayBase.cpp 13 Sep 2008 04:26:17 -0000 1.17.2.2 *************** *** 14,20 **** extern PyObject *g_obMissing; - extern void PyCom_LogF(const char *fmt, ...); - #define LogF PyCom_LogF - #include <malloc.h> // When building with the 2003 Platform SDK 64-bit compiloer, _MSC_VER is 1400, --- 14,17 ---- *************** *** 100,104 **** #ifdef DEBUG_FULL ! LogF("PyGatewayBase: created %s", m_pPyObject ? m_pPyObject->ob_type->tp_name : "<NULL>"); #endif } --- 97,101 ---- #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase: created %s", m_pPyObject ? m_pPyObject->ob_type->tp_name : "<NULL>"); #endif } *************** *** 108,112 **** InterlockedDecrement(&cGateways); #ifdef DEBUG_FULL ! LogF("PyGatewayBase: deleted %s", m_pPyObject ? m_pPyObject->ob_type->tp_name : "<NULL>"); #endif --- 105,109 ---- InterlockedDecrement(&cGateways); #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase: deleted %s", m_pPyObject ? m_pPyObject->ob_type->tp_name : "<NULL>"); #endif *************** *** 139,143 **** // Only for a special debug build, don't worry about error checking WideCharToMultiByte(CP_ACP, 0, oleRes, -1, cRes, 256, NULL, NULL); ! LogF("PyGatewayBase::QueryInterface: %s", cRes); } #endif --- 136,140 ---- // Only for a special debug build, don't worry about error checking WideCharToMultiByte(CP_ACP, 0, oleRes, -1, cRes, 256, NULL, NULL); ! PyCom_LogF("PyGatewayBase::QueryInterface: %s", cRes); } #endif *************** *** 391,395 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::GetIDsOfNames"); #endif --- 388,392 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::GetIDsOfNames"); #endif *************** *** 738,742 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::Invoke; dispid=%ld", dispid); #endif --- 735,739 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::Invoke; dispid=%ld", dispid); #endif *************** *** 778,782 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::GetDispID"); #endif PY_GATEWAY_METHOD; --- 775,779 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::GetDispID"); #endif PY_GATEWAY_METHOD; *************** *** 801,805 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::InvokeEx; dispid=%ld", id); #endif --- 798,802 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::InvokeEx; dispid=%ld", id); #endif *************** *** 843,847 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::DeleteMemberByName"); #endif PY_GATEWAY_METHOD; --- 840,844 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::DeleteMemberByName"); #endif PY_GATEWAY_METHOD; *************** *** 861,865 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::DeleteMemberByDispID"); #endif PY_GATEWAY_METHOD; --- 858,862 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::DeleteMemberByDispID"); #endif PY_GATEWAY_METHOD; *************** *** 875,879 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::GetMemberProperties"); #endif PY_GATEWAY_METHOD; --- 872,876 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::GetMemberProperties"); #endif PY_GATEWAY_METHOD; *************** *** 895,899 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::GetMemberName"); #endif PY_GATEWAY_METHOD; --- 892,896 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::GetMemberName"); #endif PY_GATEWAY_METHOD; *************** *** 912,916 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::GetNextDispID"); #endif PY_GATEWAY_METHOD; --- 909,913 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::GetNextDispID"); #endif PY_GATEWAY_METHOD; *************** *** 932,936 **** { #ifdef DEBUG_FULL ! LogF("PyGatewayBase::GetNameSpaceParent"); #endif PY_GATEWAY_METHOD; --- 929,933 ---- { #ifdef DEBUG_FULL ! PyCom_LogF("PyGatewayBase::GetNameSpaceParent"); #endif PY_GATEWAY_METHOD; Index: PyIUnknown.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIUnknown.cpp,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -C2 -d -r1.12.2.2 -r1.12.2.3 *** PyIUnknown.cpp 7 Sep 2008 02:17:18 -0000 1.12.2.2 --- PyIUnknown.cpp 13 Sep 2008 04:26:17 -0000 1.12.2.3 *************** *** 6,12 **** #include "PythonCOMServer.h" - extern void PyCom_LogF(const char *fmt, ...); - #define LogF PyCom_LogF - char *PyIUnknown::szErrMsgObjectReleased = "The COM object has been released."; --- 6,9 ---- *************** *** 50,54 **** #ifdef _DEBUG int numInMap = m_obTrackList ? PyMapping_Length(m_obTrackList) : 0; ! LogF("Cleaning up %d COM objects...", numInMap); OLECHAR FAR *pythonOb = L"pythonObject"; #endif --- 47,51 ---- #ifdef _DEBUG int numInMap = m_obTrackList ? PyMapping_Length(m_obTrackList) : 0; ! PyCom_LogF("Cleaning up %d COM objects...", numInMap); OLECHAR FAR *pythonOb = L"pythonObject"; #endif *************** *** 64,68 **** #ifdef NOPE_DEBUG const char *relDesc = pLook->m_obj ? "NOT RELEASED" : "released"; ! LogF(" object <%s> at 0x%0lx, m_obj at 0x%0lx, ob_refcnt=%d, %s", pLook->ob_type->tp_name, pLook, pLook->m_obj, pLook->ob_refcnt, relDesc); if ( pLook->m_obj ) { --- 61,65 ---- #ifdef NOPE_DEBUG const char *relDesc = pLook->m_obj ? "NOT RELEASED" : "released"; ! PyCom_LogF(" object <%s> at 0x%0lx, m_obj at 0x%0lx, ob_refcnt=%d, %s", pLook->ob_type->tp_name, pLook, pLook->m_obj, pLook->ob_refcnt, relDesc); if ( pLook->m_obj ) { *************** *** 84,92 **** if ( PyInstance_Check(ob) ) { ! LogF(" object is a Python class instance of: %s", PyString_AsString(((PyInstanceObject *)ob)->in_class->cl_name)); } else { ! LogF(" object is a Python object of type: %s", ob->ob_type->tp_name); } } --- 81,89 ---- if ( PyInstance_Check(ob) ) { ! PyCom_LogF(" object is a Python class instance of: %s", PyString_AsString(((PyInstanceObject *)ob)->in_class->cl_name)); } else { ! PyCom_LogF(" object is a Python object of type: %s", ob->ob_type->tp_name); } } *************** *** 110,114 **** } #ifdef _DEBUG ! LogF("COM object cleanup complete."); #endif } --- 107,111 ---- } #ifdef _DEBUG ! PyCom_LogF("COM object cleanup complete."); #endif } *************** *** 144,148 **** #ifdef _DEBUG_LIFETIMES ! LogF(buf, " SafeRelease(%ld) -> %s at 0x%0lx, IUnknown at 0x%0lx - Release() returned %ld",GetCurrentThreadId(), ob->ob_type->tp_name,ob, ob->m_obj,rcnt); #endif ob->m_obj = NULL; --- 141,145 ---- #ifdef _DEBUG_LIFETIMES ! PyCom_LogF(buf, " SafeRelease(%ld) -> %s at 0x%0lx, IUnknown at 0x%0lx - Release() returned %ld",GetCurrentThreadId(), ob->ob_type->tp_name,ob, ob->m_obj,rcnt); #endif ob->m_obj = NULL; *************** *** 151,155 **** { PyEval_RestoreThread(_save); ! LogF(_T("Win32 exception occurred releasing IUnknown at 0x%08x"), ob->m_obj); ob->m_obj = NULL; #ifdef _DEBUG --- 148,152 ---- { PyEval_RestoreThread(_save); ! PyCom_LogF("Win32 exception occurred releasing IUnknown at 0x%08x", ob->m_obj); ob->m_obj = NULL; #ifdef _DEBUG Index: PyStorage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -C2 -d -r1.12 -r1.12.2.1 *** PyStorage.cpp 4 Jul 2007 18:40:46 -0000 1.12 --- PyStorage.cpp 13 Sep 2008 04:26:17 -0000 1.12.2.1 *************** *** 254,258 **** myStgOpenStorageEx = (PFNStgOpenStorageEx)-1; if (ole32==NULL) ! ole32=GetModuleHandle("Ole32.dll"); if (ole32!=NULL){ FARPROC fp = GetProcAddress(ole32,"StgOpenStorageEx"); --- 254,258 ---- myStgOpenStorageEx = (PFNStgOpenStorageEx)-1; if (ole32==NULL) ! ole32=GetModuleHandle(_T("Ole32.dll")); if (ole32!=NULL){ FARPROC fp = GetProcAddress(ole32,"StgOpenStorageEx"); *************** *** 315,319 **** if (!pfnchecked){ if (ole32==NULL) ! ole32=GetModuleHandle("Ole32.dll"); if (ole32!=NULL) pfnFmtIdToPropStgName = (PFNFmtIdToPropStgName)GetProcAddress(ole32, "FmtIdToPropStgName"); --- 315,319 ---- if (!pfnchecked){ if (ole32==NULL) ! ole32=GetModuleHandle(_T("Ole32.dll")); if (ole32!=NULL) pfnFmtIdToPropStgName = (PFNFmtIdToPropStgName)GetProcAddress(ole32, "FmtIdToPropStgName"); *************** *** 352,356 **** if (!pfnchecked){ if (ole32==NULL) ! ole32=GetModuleHandle("Ole32.dll"); if (ole32!=NULL) pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(ole32, "PropStgNameToFmtId"); --- 352,356 ---- if (!pfnchecked){ if (ole32==NULL) ! ole32=GetModuleHandle(_T("Ole32.dll")); if (ole32!=NULL) pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(ole32, "PropStgNameToFmtId"); Index: dllmain.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/dllmain.cpp,v retrieving revision 1.15.4.1 retrieving revision 1.15.4.2 diff -C2 -d -r1.15.4.1 -r1.15.4.2 *** dllmain.cpp 29 Aug 2008 08:27:37 -0000 1.15.4.1 --- dllmain.cpp 13 Sep 2008 04:26:18 -0000 1.15.4.2 *************** *** 185,189 **** // Do a LoadLibrary, as the Ex version may not always exist // on Win95. ! HMODULE hMod = GetModuleHandle("ole32.dll"); if (hMod==0) return E_HANDLE; FARPROC fp = GetProcAddress(hMod, "CoInitializeEx"); --- 185,189 ---- // Do a LoadLibrary, as the Ex version may not always exist // on Win95. ! HMODULE hMod = GetModuleHandle(_T("ole32.dll")); if (hMod==0) return E_HANDLE; FARPROC fp = GetProcAddress(hMod, "CoInitializeEx"); Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.41.2.1 retrieving revision 1.41.2.2 diff -C2 -d -r1.41.2.1 -r1.41.2.2 *** oleargs.cpp 29 Aug 2008 08:27:37 -0000 1.41.2.1 --- oleargs.cpp 13 Sep 2008 04:26:18 -0000 1.41.2.2 *************** *** 6,11 **** #include "PythonCOM.h" - extern void PyCom_LogF(const TCHAR *fmt, ...); - extern PyObject *PyObject_FromRecordInfo(IRecordInfo *, void *, ULONG); extern PyObject *PyObject_FromSAFEARRAYRecordInfo(SAFEARRAY *psa); --- 6,9 ---- Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.52.2.2 retrieving revision 1.52.2.3 diff -C2 -d -r1.52.2.2 -r1.52.2.3 *** PythonCOM.cpp 29 Aug 2008 09:15:38 -0000 1.52.2.2 --- PythonCOM.cpp 13 Sep 2008 04:26:18 -0000 1.52.2.3 *************** *** 74,80 **** // Error related functions void GetScodeString(SCODE sc, TCHAR *buf, int bufSize); ! LPCSTR GetScodeRangeString(SCODE sc); ! LPCSTR GetSeverityString(SCODE sc); ! LPCSTR GetFacilityString(SCODE sc); /* Debug/Test helpers */ --- 74,80 ---- // Error related functions void GetScodeString(SCODE sc, TCHAR *buf, int bufSize); ! LPCTSTR GetScodeRangeString(SCODE sc); ! LPCTSTR GetSeverityString(SCODE sc); ! LPCTSTR GetFacilityString(SCODE sc); /* Debug/Test helpers */ *************** *** 98,102 **** static BOOL bHaveDCOM = -1; if (bHaveDCOM==-1) { ! HMODULE hMod = GetModuleHandle("ole32.dll"); if (hMod) { FARPROC fp = GetProcAddress(hMod, "CoInitializeEx"); --- 98,102 ---- static BOOL bHaveDCOM = -1; if (bHaveDCOM==-1) { ! HMODULE hMod = GetModuleHandle(_T("ole32.dll")); if (hMod) { FARPROC fp = GetProcAddress(hMod, "CoInitializeEx"); *************** *** 236,240 **** { // scoping HRESULT (STDAPICALLTYPE *mypfn)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *); ! HMODULE hMod = GetModuleHandle("ole32.dll"); if (hMod==0) { PyCom_BuildInternalPyException("Can not load ole32.dll"); --- 236,240 ---- { // scoping HRESULT (STDAPICALLTYPE *mypfn)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *); ! HMODULE hMod = GetModuleHandle(_T("ole32.dll")); if (hMod==0) { PyCom_BuildInternalPyException("Can not load ole32.dll"); *************** *** 319,323 **** return NULL; } ! HMODULE hMod = GetModuleHandle("ole32.dll"); if (hMod==0) return PyCom_BuildInternalPyException("Can not load ole32.dll"); FARPROC fp = GetProcAddress(hMod, "CoInitializeSecurity"); --- 319,323 ---- return NULL; } ! HMODULE hMod = GetModuleHandle(_T("ole32.dll")); if (hMod==0) return PyCom_BuildInternalPyException("Can not load ole32.dll"); FARPROC fp = GetProcAddress(hMod, "CoInitializeSecurity"); *************** *** 602,607 **** if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! GetScodeString(scode, buf, sizeof(buf)); ! return PyString_FromTCHAR(buf); // @comm This will obtain the COM Error message for a given HRESULT. // Internally, PythonCOM uses this function to obtain the description --- 602,607 ---- if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! GetScodeString(scode, buf, sizeof(buf)/sizeof(buf[0])); ! return PyWinObject_FromTCHAR(buf); // @comm This will obtain the COM Error message for a given HRESULT. // Internally, PythonCOM uses this function to obtain the description *************** *** 616,620 **** if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! return Py_BuildValue("z", GetScodeRangeString(scode) ); } --- 616,620 ---- if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! return PyWinObject_FromTCHAR(GetScodeRangeString(scode)); } *************** *** 626,630 **** if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! return Py_BuildValue("z", GetSeverityString(scode) ); } --- 626,630 ---- if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! return PyWinObject_FromTCHAR(GetSeverityString(scode)); } *************** *** 636,640 **** if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! return Py_BuildValue("z", GetFacilityString(scode) ); } --- 636,640 ---- if (!PyArg_ParseTuple(args, "k", &scode)) return NULL; ! return PyWinObject_FromTCHAR(GetFacilityString(scode)); } *************** *** 1769,1773 **** // GIL protects us from races here. if (pfnObjectFromLresult==NULL) { ! HMODULE hmod = LoadLibrary("oleacc.dll"); if (hmod) pfnObjectFromLresult = (LPFNOBJECTFROMLRESULT) --- 1769,1773 ---- // GIL protects us from races here. if (pfnObjectFromLresult==NULL) { ! HMODULE hmod = LoadLibrary(_T("oleacc.dll")); if (hmod) pfnObjectFromLresult = (LPFNOBJECTFROMLRESULT) *************** *** 2086,2090 **** // Load function pointers. ! HMODULE hModOle32 = GetModuleHandle("ole32.dll"); pfnCoWaitForMultipleHandles = \ (HRESULT (STDAPICALLTYPE *)(DWORD, DWORD, ULONG, LPHANDLE, LPDWORD)) \ --- 2086,2090 ---- // Load function pointers. ! HMODULE hModOle32 = GetModuleHandle(_T("ole32.dll")); pfnCoWaitForMultipleHandles = \ (HRESULT (STDAPICALLTYPE *)(DWORD, DWORD, ULONG, LPHANDLE, LPDWORD)) \ Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.30.2.2 retrieving revision 1.30.2.3 diff -C2 -d -r1.30.2.2 -r1.30.2.3 *** ErrorUtils.cpp 31 Aug 2008 02:11:04 -0000 1.30.2.2 --- ErrorUtils.cpp 13 Sep 2008 04:26:17 -0000 1.30.2.3 *************** *** 14,20 **** void GetScodeString(SCODE sc, TCHAR *buf, int bufSize); ! LPCSTR GetScodeRangeString(SCODE sc); ! LPCSTR GetSeverityString(SCODE sc); ! LPCSTR GetFacilityString(SCODE sc); static PyObject *PyCom_PyObjectFromIErrorInfo(IErrorInfo *, HRESULT errorhr); --- 14,20 ---- void GetScodeString(SCODE sc, TCHAR *buf, int bufSize); ! LPCTSTR GetScodeRangeString(SCODE sc); ! LPCTSTR GetSeverityString(SCODE sc); ! LPCTSTR GetFacilityString(SCODE sc); static PyObject *PyCom_PyObjectFromIErrorInfo(IErrorInfo *, HRESULT errorhr); *************** *** 53,73 **** PyErr_Clear(); // Not a special exception object - do the best we can. - PyObject *obException = PyObject_Str(exception); - PyObject *obValue = PyObject_Str(v); - char *szException = PyString_AsString(obException); - char *szValue = PyString_AsString(obValue); char *szBaseMessage = "Unexpected Python Error: "; ! if (szException==NULL) szException = "<bad exception>"; ! if (szValue==NULL) szValue = "<bad exception value>"; ! size_t len = strlen(szBaseMessage) + strlen(szException) + 2 + strlen(szValue) + 1; ! // 2 for ": " ! // message could be quite long - be safe. char *tempBuf = new char[len]; if (tempBuf) { ! strcpy(tempBuf, szBaseMessage); ! strcat(tempBuf, szException); ! strcat(tempBuf, ": "); ! strcat(tempBuf, szValue); pExcepInfo->bstrDescription = PyWin_String_AsBstr(tempBuf); } else pExcepInfo->bstrDescription = SysAllocString(L"memory error allocating exception buffer!"); --- 53,64 ---- PyErr_Clear(); // Not a special exception object - do the best we can. char *szBaseMessage = "Unexpected Python Error: "; ! char *szException = GetPythonTraceback(exception, v, tb); ! size_t len = strlen(szBaseMessage) + strlen(szException) + 1; char *tempBuf = new char[len]; if (tempBuf) { ! snprintf(tempBuf, len, "%s%s", szBaseMessage, szException); pExcepInfo->bstrDescription = PyWin_String_AsBstr(tempBuf); + delete [] tempBuf; } else pExcepInfo->bstrDescription = SysAllocString(L"memory error allocating exception buffer!"); *************** *** 82,93 **** // Any other common Python exceptions we should map? pExcepInfo->scode = E_FAIL; - - delete [] tempBuf; - Py_XDECREF(obException); - Py_XDECREF(obValue); } - Py_XDECREF(tb); Py_XDECREF(exception); Py_XDECREF(v); PyErr_Clear(); } --- 73,80 ---- // Any other common Python exceptions we should map? pExcepInfo->scode = E_FAIL; } Py_XDECREF(exception); Py_XDECREF(v); + Py_XDECREF(tb); PyErr_Clear(); } *************** *** 372,376 **** { #ifndef MS_WINCE ! OutputDebugString(pszMessageText); #else NKDbgPrintfW(pszMessageText); --- 359,363 ---- { #ifndef MS_WINCE ! OutputDebugStringA(pszMessageText); #else NKDbgPrintfW(pszMessageText); *************** *** 390,402 **** BOOL VLogF_Logger(PyObject *logger, const char *log_method, ! const TCHAR *prefix, const TCHAR *fmt, va_list argptr) { // Protected by Python lock ! static TCHAR buff[8196]; size_t buf_len = sizeof(buff) / sizeof(buff[0]); size_t prefix_len = strlen(prefix); ! assert(prefix_len<100); ! strcpy(buff, prefix); ! wvsprintf(buff+prefix_len, fmt, argptr); PyObject *exc_typ = NULL, *exc_val = NULL, *exc_tb = NULL; --- 377,388 ---- BOOL VLogF_Logger(PyObject *logger, const char *log_method, ! const char *prefix, const char *fmt, va_list argptr) { // Protected by Python lock ! static char buff[8196]; size_t buf_len = sizeof(buff) / sizeof(buff[0]); size_t prefix_len = strlen(prefix); ! strncpy(buff, prefix, buf_len); ! vsnprintf(buff+prefix_len, buf_len-prefix_len, fmt, argptr); PyObject *exc_typ = NULL, *exc_val = NULL, *exc_tb = NULL; *************** *** 433,446 **** } ! void VLogF(const TCHAR *fmt, va_list argptr) { ! static TCHAR buff[8196]; // protected by Python lock ! wvsprintf(buff, fmt, argptr); PyCom_StreamMessage(buff); } ! PYCOM_EXPORT void PyCom_LogF(const TCHAR *fmt, ...) { va_list marker; --- 419,432 ---- } ! void VLogF(const char *fmt, va_list argptr) { ! static char buff[8196]; // protected by Python lock ! vsnprintf(buff, 8196, fmt, argptr); PyCom_StreamMessage(buff); } ! void PyCom_LogF(const char *fmt, ...) { va_list marker; *************** *** 590,594 **** Py_INCREF(Py_None); } ! PyObject *evalue = Py_BuildValue("isOO", errorhr, scodeStringBuf, obEI, Py_None); Py_DECREF(obEI); --- 576,580 ---- Py_INCREF(Py_None); } ! PyObject *evalue = Py_BuildValue("iNOO", errorhr, PyWinObject_FromTCHAR(scodeStringBuf), obEI, Py_None); Py_DECREF(obEI); *************** *** 605,609 **** TCHAR buf[512]; GetScodeString(hr, buf, sizeof(buf)/sizeof(TCHAR)); ! PyObject *obScodeString = PyString_FromTCHAR(buf); PyObject *evalue; PyObject *obArg; --- 591,595 ---- TCHAR buf[512]; GetScodeString(hr, buf, sizeof(buf)/sizeof(TCHAR)); ! PyObject *obScodeString = PyWinObject_FromTCHAR(buf); PyObject *evalue; PyObject *obArg; *************** *** 1066,1070 **** return; } ! // Next see if this particular error code is registerd as being supplied // by a specific DLL. HINSTANCE hi = PyWin_GetErrorMessageModule(hr); --- 1052,1056 ---- return; } ! // Next see if this particular error code is registered as being supplied // by a specific DLL. HINSTANCE hi = PyWin_GetErrorMessageModule(hr); *************** *** 1093,1097 **** } ! LPCSTR GetScodeRangeString(HRESULT hr) { struct RANGE_ENTRY --- 1079,1083 ---- } ! LPCTSTR GetScodeRangeString(HRESULT hr) { struct RANGE_ENTRY *************** *** 1099,1107 **** HRESULT hrFirst; HRESULT hrLast; ! LPCSTR lpszName; }; #define MAKE_RANGE_ENTRY(hrRange) \ { hrRange##_FIRST, hrRange##_LAST, \ ! #hrRange "_FIRST..." #hrRange "_LAST" } static const RANGE_ENTRY hrRangeTable[] = --- 1085,1093 ---- HRESULT hrFirst; HRESULT hrLast; ! LPCTSTR lpszName; }; #define MAKE_RANGE_ENTRY(hrRange) \ { hrRange##_FIRST, hrRange##_LAST, \ ! _T(#hrRange) _T("_FIRST...") _T(#hrRange) _T("_LAST") } static const RANGE_ENTRY hrRangeTable[] = *************** *** 1154,1198 **** } ! LPCSTR GetSeverityString(HRESULT hr) { ! static LPCSTR rgszSEVERITY[] = { ! "SEVERITY_SUCCESS", ! "SEVERITY_ERROR", }; return rgszSEVERITY[HRESULT_SEVERITY(hr)]; } ! LPCSTR GetFacilityString(HRESULT hr) { ! static LPCSTR rgszFACILITY[] = { ! "FACILITY_NULL", ! "FACILITY_RPC", ! "FACILITY_DISPATCH", ! "FACILITY_STORAGE", ! "FACILITY_ITF", ! "FACILITY_ADSI", ! "FACILITY_0x06", ! "FACILITY_WIN32", ! "FACILITY_WINDOWS", ! "FACILITY_SSPI/FACILITY_MQ", // SSPI from ADSERR.H, MQ from mq.h ! "FACILITY_CONTROL", ! "FACILITY_EDK", ! "FACILITY_INTERNET", ! "FACILITY_MEDIASERVER", ! "FACILITY_MSMQ", ! "FACILITY_SETUPAPI", }; if (HRESULT_FACILITY(hr) >= _countof(rgszFACILITY)) switch (HRESULT_FACILITY(hr)) { case 0x7FF: ! return "FACILITY_BACKUP"; case 0x800: ! return "FACILITY_EDB"; case 0x900: ! return "FACILITY_MDSI"; default: ! return "<Unknown Facility>"; } return rgszFACILITY[HRESULT_FACILITY(hr)]; --- 1140,1184 ---- } ! LPCTSTR GetSeverityString(HRESULT hr) { ! static LPCTSTR rgszSEVERITY[] = { ! _T("SEVERITY_SUCCESS"), ! _T("SEVERITY_ERROR"), }; return rgszSEVERITY[HRESULT_SEVERITY(hr)]; } ! LPCTSTR GetFacilityString(HRESULT hr) { ! static LPCTSTR rgszFACILITY[] = { ! _T("FACILITY_NULL"), ! _T("FACILITY_RPC"), ! _T("FACILITY_DISPATCH"), ! _T("FACILITY_STORAGE"), ! _T("FACILITY_ITF"), ! _T("FACILITY_ADSI"), ! _T("FACILITY_0x06"), ! _T("FACILITY_WIN32"), ! _T("FACILITY_WINDOWS"), ! _T("FACILITY_SSPI/FACILITY_MQ"), // SSPI from ADSERR.H, MQ from mq.h ! _T("FACILITY_CONTROL"), ! _T("FACILITY_EDK"), ! _T("FACILITY_INTERNET"), ! _T("FACILITY_MEDIASERVER"), ! _T("FACILITY_MSMQ"), ! _T("FACILITY_SETUPAPI"), }; if (HRESULT_FACILITY(hr) >= _countof(rgszFACILITY)) switch (HRESULT_FACILITY(hr)) { case 0x7FF: ! return _T("FACILITY_BACKUP"); case 0x800: ! return _T("FACILITY_EDB"); case 0x900: ! return _T("FACILITY_MDSI"); default: ! return _T("<Unknown Facility>"); } return rgszFACILITY[HRESULT_FACILITY(hr)]; Index: PyRecord.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyRecord.cpp,v retrieving revision 1.11.4.1 retrieving revision 1.11.4.2 diff -C2 -d -r1.11.4.1 -r1.11.4.2 *** PyRecord.cpp 29 Aug 2008 08:27:37 -0000 1.11.4.1 --- PyRecord.cpp 13 Sep 2008 04:26:17 -0000 1.11.4.2 *************** *** 24,28 **** static HRESULT (STDAPICALLTYPE *pfnSAGRI)(SAFEARRAY *, IRecordInfo **) = NULL; if (pfnSAGRI==NULL) { ! HMODULE hmod = GetModuleHandle("oleaut32.dll"); if (hmod==NULL) return E_NOTIMPL; --- 24,28 ---- static HRESULT (STDAPICALLTYPE *pfnSAGRI)(SAFEARRAY *, IRecordInfo **) = NULL; if (pfnSAGRI==NULL) { ! HMODULE hmod = GetModuleHandle(_T("oleaut32.dll")); if (hmod==NULL) return E_NOTIMPL; *************** *** 38,42 **** static HRESULT (STDAPICALLTYPE *pfnGRIFG)(REFGUID, ULONG, ULONG, LCID, REFGUID, IRecordInfo **) = NULL; if (pfnGRIFG==NULL) { ! HMODULE hmod = GetModuleHandle("oleaut32.dll"); if (hmod==NULL) return E_NOTIMPL; --- 38,42 ---- static HRESULT (STDAPICALLTYPE *pfnGRIFG)(REFGUID, ULONG, ULONG, LCID, REFGUID, IRecordInfo **) = NULL; if (pfnGRIFG==NULL) { ! HMODULE hmod = GetModuleHandle(_T("oleaut32.dll")); if (hmod==NULL) return E_NOTIMPL; |