Patches item #2630059, was opened at 2009-02-23 13:53
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551956&aid=2630059&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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Michael Neuroth (mindia)
Assigned to: Nobody/Anonymous (nobody)
Summary: patch for genpy.py to improve support for constants class
Initial Comment:
With the build 213 I had problems with a COM class when using genpy.py. The COM class has no constants defined but the method Generator.do_generate() in the genpy.py file had problems to generate a valid python class. The following construct was generated:
...
MajorVersion = 1
MinorVersion = 1
LibraryFlags = 8
LCID = 0x0
class constants:
from win32com.client import DispatchBaseClass
class IMyInterface(DispatchBaseClass):
"""IMyInterface Interface"""
...
Unfortunately this code is not a valid python code.
I appied the following patch to genpy.py which helped me to fix this problem. Maybe a similar patch could be included into the original source code?
======= Modifications in genpy.py ==========
def do_generate(self):
...
# Generate the constants and their support.
if enumItems:
iTotalCount = 0 # PATCH
print >> stream, "class constants:"
items = enumItems.values()
items.sort()
for oleitem in items:
iTotalCount += oleitem.WriteEnumerationItems(stream) # PATCH
self.progress.Tick()
if iTotalCount==0: # PATCH
print >> stream, "\tpass" # PATCH
print >> stream
...
class EnumerationItem(build.OleItem, WriteableItem):
...
def WriteEnumerationItems(self, stream):
enumName = self.doc[0]
iItemCount = 0 # PATCH
# Write in name alpha order
names = list(self.mapVars.keys())
names.sort()
for name in names:
entry = self.mapVars[name]
vdesc = entry.desc
if vdesc[4] == pythoncom.VAR_CONST:
val = vdesc[1]
if sys.version_info <= (2,4) and (isinstance(val, int) or isinstance(val, long)):
# in python 2.3, 0x80000000L == 2147483648
if val==2147483648: # == 0x80000000L - special case for 2.3...
use = "0x80000000L" # 'L' for future warning
elif val > 2147483648 or val < 0: # avoid a FutureWarning
use = long(val)
else:
use = hex(val)
else:
use = repr(val)
print >> stream, "\t%-30s=%-10s # from enum %s" % \
(build.MakePublicAttributeName(name, True), use, enumName)
iItemCount += 1 # PATCH
return iItemCount # PATCH
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551956&aid=2630059&group_id=78018
|