[pywin32-bugs] [ pywin32-Bugs-1935488 ] gencache and Delphi Currency
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2008-04-08 21:19:10
|
Bugs item #1935488, was opened at 2008-04-06 02:49 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1935488&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: com Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Santi Wangkerkoon (santiwk) Assigned to: Nobody/Anonymous (nobody) Summary: gencache and Delphi Currency Initial Comment: Delphi snippet: procedure Setprice(PriceLevel: Smallint; pVal: Currency); As pywin32-210's makepy and gencache comes: def Setprice(self, PriceLevel=defaultNamedNotOptArg, arg1=defaultUnnamedArg): return self._oleobj_.InvokeTypes(4, LCID, 4, (24, 0), ((2, 0), (6, 1)),PriceLevel, arg1) Calling Setprice() causes Variant exception! I had to change the above python from (6, 1) to (4, 1) The effect is to change (pVal: Currency) to (pVal: Single) Is there any other way around ? ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2008-04-09 07:19 Message: Logged In: YES user_id=14198 Originator: NO Thanks for testing this so quickly! I believe there is no auto conversion as it is impossible to convert between floats and decimals without losing precision (ie, one of the main reasons decimal/currency exists is because it is so much more accurate than floats - and losing this extra accuracy silently would be bad. ---------------------------------------------------------------------- Comment By: Santi Wangkerkoon (santiwk) Date: 2008-04-09 02:20 Message: Logged In: YES user_id=1445373 Originator: YES pywin32-210.9.win32-py2.5 works great! I just wonder why there is no implicit conversion between float/double and Decimal. But that is python story, not pywin32's. Thank you Mr Hammond, for your promptly fix. >>> from win32com.client import Dispatch >>> from decimal import Decimal >>> Ax = Dispatch('Pycurr.PyCurrency') >>> Ax.SetpriceCurr(Decimal('100.0')) >>> Ax.SetpriceCurr(100.0) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<COMObject Pycurr.PyCurrency>", line 2, in SetpriceCurr TypeError: Currency object must be either a tuple of 2 longs or a Decimal instance (got float). ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2008-04-08 21:55 Message: Logged In: YES user_id=14198 Originator: NO I think I just checked in a fix for this. Would it be possible for you to test starship.python.net/crew/mhammond/pywin32-210.9.win32-py2.5.exe ? Checking in TestSources/PyCOMTest/PyCOMImpl.cpp; new revision: 1.18; previous revision: 1.17 Checking in TestSources/PyCOMTest/PyCOMImpl.h; new revision: 1.16; previous revision: 1.15 Checking in TestSources/PyCOMTest/PyCOMTest.idl; new revision: 1.17; previous revision: 1.16 Checking in win32com/src/oleargs.cpp; new revision: 1.41; previous revision: 1.40 Checking in win32com/src/include/PythonCOM.h; new revision: 1.27; previous revision: 1.26 Checking in win32com/test/testPyComTest.py; new revision: 1.30; previous revision: 1.29 ---------------------------------------------------------------------- Comment By: Santi Wangkerkoon (santiwk) Date: 2008-04-08 00:06 Message: Logged In: YES user_id=1445373 Originator: YES Delete psrvr.zip (Typelib and TRegSvr). TRegSvr is not required, just run PyCurr.exe for register. ---------------------------------------------------------------------- Comment By: Santi Wangkerkoon (santiwk) Date: 2008-04-07 06:05 Message: Logged In: YES user_id=1445373 Originator: YES psrvr.exe source code is not available, so I write a small PyCurr.exe for your testing. Here is the screen shot: c:\>tregsvr PyCurr.exe >>> from win32com.client import Dispatch >>> Ax = Dispatch('PyCurr.PyCurrency') >>> Ax.SetpriceFloat(100.0) >>> Ax.SetpriceDouble(100.0) >>> Ax.SetpriceCurr(100.0) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<COMObject PyCurr.PyCurrency>", line 2, in SetpriceCurr TypeError: The VARIANT type is unknown (00000006) File Added: PyCurr.zip ---------------------------------------------------------------------- Comment By: Santi Wangkerkoon (santiwk) Date: 2008-04-06 17:12 Message: Logged In: YES user_id=1445373 Originator: YES The typelib is in .exe file. So I send it with register tool. (regsvr32 won't work.) The steps I test :- ...tregsvr psrvr.exe ...makepy.py: psrvr 1.0 File Added: psrvr.zip ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2008-04-06 09:08 Message: Logged In: YES user_id=14198 Originator: NO I can't think if why this would have changed. Is it possible the COM object itself changed? Can you send me the typelib? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1935488&group_id=78018 |