Skip to content

Commit

Permalink
Handle case if typelib path is not set.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasily-v-ryabov committed Feb 28, 2021
1 parent 121f8e1 commit b7e47af
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions comtypes/tools/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,15 @@ def generate_code(self, items, filename=None):
for line in wrapper.wrap(text):
print >> self.output, line

# get full path to DLL first (os.stat can't work with relative DLL paths properly)
loaded_typelib = comtypes.typeinfo.LoadTypeLib(self.filename)
full_filename = comtypes.tools.tlbparser.get_tlib_filename(loaded_typelib)
tlib_mtime = None
if self.filename is not None:
# get full path to DLL first (os.stat can't work with relative DLL paths properly)
loaded_typelib = comtypes.typeinfo.LoadTypeLib(self.filename)
full_filename = comtypes.tools.tlbparser.get_tlib_filename(loaded_typelib)

# get DLL timestamp at the moment of wrapper generation
tlib_mtime = os.stat(full_filename).st_mtime

# get DLL timestamp at the moment of wrapper generation
tlib_mtime = os.stat(full_filename).st_mtime
print >> self.output, "from comtypes import _check_version; _check_version(%r, %f)" % (version, tlib_mtime)
return loops

Expand Down

0 comments on commit b7e47af

Please sign in to comment.