[pywin32-bugs] [ pywin32-Bugs-2934871 ] makepy stops on None-encoding
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2010-01-26 17:17:38
|
Bugs item #2934871, was opened at 2010-01-19 05:22 Message generated for change (Comment added) made by rupole You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2934871&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: Harald Armin Massa (ghum) Assigned to: Nobody/Anonymous (nobody) Summary: makepy stops on None-encoding Initial Comment: 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 -*- this patch is put into public domain. ---------------------------------------------------------------------- >Comment By: Roger Upole (rupole) Date: 2010-01-26 12:17 Message: Thanks, fixed in makepy.py r1.29. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2934871&group_id=78018 |