Skip to content

Commit

Permalink
Removed Python 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
SReicheltPTV committed Oct 22, 2020
1 parent 594b50f commit 7e377bb
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions com/win32com/client/makepy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,10 @@
"""

import sys, os, pythoncom
import sys, os, importlib, pythoncom
from win32com.client import genpy, selecttlb, gencache
from win32com.client import Dispatch

try:
import importlib
except:
# We only need importlib for invalidate_caches.
# In old Python versions without importlib, there is nothing to invalidate.
pass

bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also gencache.py

error = "makepy.error"
Expand Down Expand Up @@ -288,8 +281,7 @@ def GenerateFromTypeLibSpec(typelibInfo, file = None, verboseLevel = None, progr
finally:
if file is None:
gen.finish_writer(outputName, fileUse, worked)
if 'importlib' in sys.modules and hasattr(importlib, 'invalidate_caches'):
importlib.invalidate_caches()
importlib.invalidate_caches()
if bToGenDir:
progress.SetDescription("Importing module")
gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor)
Expand Down Expand Up @@ -326,8 +318,7 @@ def GenerateChildFromTypeLibSpec(child, typelibInfo, verboseLevel = None, progre
gen = genpy.Generator(typelib, info.dll, progress)
gen.generate_child(child, dir_path_name)
progress.SetDescription("Importing module")
if 'importlib' in sys.modules and hasattr(importlib, 'invalidate_caches'):
importlib.invalidate_caches()
importlib.invalidate_caches()
__import__("win32com.gen_py." + dir_name + "." + child)
progress.Close()

Expand Down

0 comments on commit 7e377bb

Please sign in to comment.