Show More
@@ -1,5 +1,6 b'' | |||
|
1 | 1 | # coding: utf-8 |
|
2 | 2 | """Compatibility tricks for Python 3. Mainly to do with unicode.""" |
|
3 | import __builtin__ | |
|
3 | 4 | import functools |
|
4 | 5 | import sys |
|
5 | 6 | import re |
@@ -151,13 +152,21 b' else:' | |||
|
151 | 152 | Accepts a string or a function, so it can be used as a decorator.""" |
|
152 | 153 | return s.format(u='u') |
|
153 | 154 | |
|
154 | def execfile(fname, glob, loc=None): | |
|
155 | loc = loc if (loc is not None) else glob | |
|
156 | scripttext = file(fname).read() | |
|
157 | #compile converts unicode filename to str assuming | |
|
158 | #ascii. Let's do the conversion before calling compile | |
|
159 | if isinstance(fname, unicode): | |
|
160 |
|
|
|
161 | else: | |
|
162 |
|
|
|
163 | exec compile(scripttext, filename, 'exec') in glob, loc | |
|
155 | if sys.platform == 'win32': | |
|
156 | def execfile(fname, glob, loc=None): | |
|
157 | loc = loc if (loc is not None) else glob | |
|
158 | scripttext = file(fname).read() | |
|
159 | #compile converts unicode filename to str assuming | |
|
160 | #ascii. Let's do the conversion before calling compile | |
|
161 | if isinstance(fname, unicode): | |
|
162 | filename = unicode_to_str(fname) | |
|
163 | else: | |
|
164 | filename = fname | |
|
165 | exec compile(scripttext, filename, 'exec') in glob, loc | |
|
166 | else: | |
|
167 | def execfile(fname, glob, loc=None): | |
|
168 | if isinstance(fname, unicode): | |
|
169 | filename = fname.encode(sys.getfilesystemencoding()) | |
|
170 | else: | |
|
171 | filename = fname | |
|
172 | __builtin__.execfile(filename, glob, loc) |
General Comments 0
You need to be logged in to leave comments.
Login now