Patches item #3028046, was opened at 2010-07-11 07:02
Message generated for change (Comment added) made by rupole
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551956&aid=3028046&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: Closed
>Resolution: Out of Date
Priority: 5
Private: No
Submitted By: Harald Armin Massa (ghum)
Assigned to: Nobody/Anonymous (nobody)
Summary: patch to reenable makepy.py / against missing encoding error
Initial Comment:
in Version 213 of pywin32 within
win32com\client\genpy.py
on line 814, within def do_gen_file_header(self): there is the assertion:
# You must provide a file correctly configured for writing unicode.
# We assert this is it may indicate somewhere in pywin32 that needs
# upgrading.
assert self.file.encoding, self.file
But using makepy.py via
makepy.py -v -o OLE_Excel11.py "Microsoft Excel 11.0 Object Library"
this assertion fails ... as self.file.encoding is None
The culprit is makepy.py itself:
starting at line 367ff there is:
if outputName is not None:
path = os.path.dirname(outputName)
if path is not '' and not os.path.exists(path):
os.makedirs(path)
f = open(outputName, "w")
else:
f = None
and this "f" will have encoding=None
I patched this to:
if outputName is not None:
path = os.path.dirname(outputName)
if path is not '' and not os.path.exists(path):
os.makedirs(path)
#~ f = open(outputName, "w")
import codecs
f= codecs.open(outputName, mode="w",encoding="mbcs")
else:
f = None
use codecs to create a file with mbcs encoding. After this, I get a nice create ole_excel11.py file, with the good line
# -*- coding: mbcs -*-
at the beginning.
I propose to put this fix into makepy.py for everybody; (any rights you need are hereby granted)
----------------------------------------------------------------------
>Comment By: Roger Upole (rupole)
Date: 2010-07-11 17:14
Message:
Thanks for the patch! However, this is already fixed in r1.29.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551956&aid=3028046&group_id=78018
|