##// END OF EJS Templates
Backport PR #4928: user importlib.machinery when available
Thomas Kluyver -
Show More
@@ -17,12 +17,19 b' from __future__ import print_function'
17 17
18 18 # Stdlib imports
19 19 import glob
20 import imp
21 20 import inspect
22 21 import os
23 22 import re
24 23 import sys
25 24
25 try:
26 # Python 3
27 from importlib.machinery import all_suffixes
28 _suffixes = all_suffixes()
29 except ImportError:
30 from imp import get_suffixes
31 _suffixes = [ s[0] for s in get_suffixes() ]
32
26 33 # Third-party imports
27 34 from time import time
28 35 from zipimport import zipimporter
@@ -50,7 +57,7 b' TIMEOUT_GIVEUP = 20'
50 57 import_re = re.compile(r'(?P<name>[a-zA-Z_][a-zA-Z0-9_]*?)'
51 58 r'(?P<package>[/\\]__init__)?'
52 59 r'(?P<suffix>%s)$' %
53 r'|'.join(re.escape(s[0]) for s in imp.get_suffixes()))
60 r'|'.join(re.escape(s[0]) for s in _suffixes))
54 61
55 62 # RE for the ipython %run command (python + ipython scripts)
56 63 magic_run_re = re.compile(r'.*(\.ipy|\.py[w]?)$')
General Comments 0
You need to be logged in to leave comments. Login now