Show More
@@ -2914,7 +2914,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2914 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) |
|
2914 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) | |
2915 | return "\n".join(x for _, _, x in lines) |
|
2915 | return "\n".join(x for _, _, x in lines) | |
2916 |
|
2916 | |||
2917 | def find_user_code(self, target, raw=True, py_only=False): |
|
2917 | def find_user_code(self, target, raw=True, py_only=False, skip_encoding_cookie=True): | |
2918 | """Get a code string from history, file, url, or a string or macro. |
|
2918 | """Get a code string from history, file, url, or a string or macro. | |
2919 |
|
2919 | |||
2920 | This is mainly used by magic functions. |
|
2920 | This is mainly used by magic functions. | |
@@ -2951,7 +2951,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2951 | utarget = unquote_filename(target) |
|
2951 | utarget = unquote_filename(target) | |
2952 | try: |
|
2952 | try: | |
2953 | if utarget.startswith(('http://', 'https://')): |
|
2953 | if utarget.startswith(('http://', 'https://')): | |
2954 |
return openpy.read_py_url(utarget, skip_encoding_cookie= |
|
2954 | return openpy.read_py_url(utarget, skip_encoding_cookie=skip_encoding_cookie) | |
2955 | except UnicodeDecodeError: |
|
2955 | except UnicodeDecodeError: | |
2956 | if not py_only : |
|
2956 | if not py_only : | |
2957 | response = urllib.urlopen(target) |
|
2957 | response = urllib.urlopen(target) | |
@@ -2967,7 +2967,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2967 | for tgt in potential_target : |
|
2967 | for tgt in potential_target : | |
2968 | if os.path.isfile(tgt): # Read file |
|
2968 | if os.path.isfile(tgt): # Read file | |
2969 | try : |
|
2969 | try : | |
2970 |
return openpy.read_py_file(tgt, skip_encoding_cookie= |
|
2970 | return openpy.read_py_file(tgt, skip_encoding_cookie=skip_encoding_cookie) | |
2971 | except UnicodeDecodeError : |
|
2971 | except UnicodeDecodeError : | |
2972 | if not py_only : |
|
2972 | if not py_only : | |
2973 | with io_open(tgt,'r', encoding='latin1') as f : |
|
2973 | with io_open(tgt,'r', encoding='latin1') as f : |
@@ -687,7 +687,7 b' class OSMagics(Magics):' | |||||
687 | 'or macro.') |
|
687 | 'or macro.') | |
688 |
|
688 | |||
689 | try : |
|
689 | try : | |
690 | cont = self.shell.find_user_code(parameter_s) |
|
690 | cont = self.shell.find_user_code(parameter_s, skip_encoding_cookie=False) | |
691 | except (ValueError, IOError): |
|
691 | except (ValueError, IOError): | |
692 | print "Error: no such file, variable, URL, history range or macro" |
|
692 | print "Error: no such file, variable, URL, history range or macro" | |
693 | return |
|
693 | return |
General Comments 0
You need to be logged in to leave comments.
Login now