Created
May 31, 2016 00:09
-
-
Save MattDMo/56c5e4f9cc00402a4e03e5044527517d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*************************************************************************** | |
IPython post-mortem report | |
{'commit_hash': 'c963f6b', | |
'commit_source': 'installation', | |
'default_encoding': 'UTF-8', | |
'ipython_path': '/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython', | |
'ipython_version': '4.2.0', | |
'os_name': 'posix', | |
'platform': 'Darwin-12.5.0-x86_64-i386-64bit', | |
'sys_executable': '/opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5', | |
'sys_platform': 'darwin', | |
'sys_version': '3.5.1 (default, Mar 2 2016, 00:45:44) \n' | |
'[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]'} | |
*************************************************************************** | |
*************************************************************************** | |
Crash traceback: | |
--------------------------------------------------------------------------- | |
--------------------------------------------------------------------------- | |
AttributeErrorPython 3.5.1: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 | |
Mon May 30 20:02:21 2016 | |
A problem occurred executing Python code. Here is the sequence of function | |
calls leading up to the error, with the most recent (innermost) call last. | |
/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/ipython3 in <module>() | |
1 #!/opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 | |
2 | |
3 # -*- coding: utf-8 -*- | |
4 import re | |
5 import sys | |
6 | |
7 from IPython import start_ipython | |
8 | |
9 if __name__ == '__main__': | |
10 sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | |
---> 11 sys.exit(start_ipython()) | |
global sys.exit = <built-in function exit> | |
global start_ipython = <function start_ipython at 0x10378ce18> | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/__init__.py in start_ipython(argv=None, **kwargs={}) | |
104 This is a public API method, and will survive implementation changes. | |
105 | |
106 Parameters | |
107 ---------- | |
108 | |
109 argv : list or None, optional | |
110 If unspecified or None, IPython will parse command-line options from sys.argv. | |
111 To prevent any command-line parsing, pass an empty list: `argv=[]`. | |
112 user_ns : dict, optional | |
113 specify this dictionary to initialize the IPython user namespace with particular values. | |
114 kwargs : various, optional | |
115 Any other kwargs will be passed to the Application constructor, | |
116 such as `config`. | |
117 """ | |
118 from IPython.terminal.ipapp import launch_new_instance | |
--> 119 return launch_new_instance(argv=argv, **kwargs) | |
launch_new_instance = <bound method Application.launch_instance of <class 'IPython.terminal.ipapp.TerminalIPythonApp'>> | |
argv = None | |
kwargs = {} | |
120 | |
121 def start_kernel(argv=None, **kwargs): | |
122 """Launch a normal IPython kernel instance (as opposed to embedded) | |
123 | |
124 `IPython.embed_kernel()` puts a shell in a particular calling scope, | |
125 such as a function or method for debugging purposes, | |
126 which is often not desirable. | |
127 | |
128 `start_kernel()` does full, regular IPython initialization, | |
129 including loading startup files, configuration, etc. | |
130 much of which is skipped by `embed()`. | |
131 | |
132 Parameters | |
133 ---------- | |
134 | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'IPython.terminal.ipapp.TerminalIPythonApp'>, argv=None, **kwargs={}) | |
580 lines.append(cls.class_config_section()) | |
581 return '\n'.join(lines) | |
582 | |
583 def exit(self, exit_status=0): | |
584 self.log.debug("Exiting application: %s" % self.name) | |
585 logging.shutdown() | |
586 sys.exit(exit_status) | |
587 | |
588 @classmethod | |
589 def launch_instance(cls, argv=None, **kwargs): | |
590 """Launch a global instance of this Application | |
591 | |
592 If a global instance already exists, this reinitializes and starts it | |
593 """ | |
594 app = cls.instance(**kwargs) | |
--> 595 app.initialize(argv) | |
app.initialize = <bound method TerminalIPythonApp.initialize of <IPython.terminal.ipapp.TerminalIPythonApp object at 0x10321fb70>> | |
argv = None | |
596 app.start() | |
597 | |
598 #----------------------------------------------------------------------------- | |
599 # utility functions, for convenience | |
600 #----------------------------------------------------------------------------- | |
601 | |
602 def boolean_flag(name, configurable, set_help='', unset_help=''): | |
603 """Helper for building basic --trait, --no-trait flags. | |
604 | |
605 Parameters | |
606 ---------- | |
607 | |
608 name : str | |
609 The name of the flag. | |
610 configurable : str | |
<decorator-gen-111> in initialize(self=<IPython.terminal.ipapp.TerminalIPythonApp object>, argv=None) | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/application.py in catch_config_error(method=<function TerminalIPythonApp.initialize>, app=<IPython.terminal.ipapp.TerminalIPythonApp object>, *args=(None,), **kwargs={}) | |
59 | |
60 #----------------------------------------------------------------------------- | |
61 # Application class | |
62 #----------------------------------------------------------------------------- | |
63 | |
64 @decorator | |
65 def catch_config_error(method, app, *args, **kwargs): | |
66 """Method decorator for catching invalid config (Trait/ArgumentErrors) during init. | |
67 | |
68 On a TraitError (generally caused by bad config), this will print the trait's | |
69 message, and exit the app. | |
70 | |
71 For use on init methods, to prevent invoking excepthook on invalid input. | |
72 """ | |
73 try: | |
---> 74 return method(app, *args, **kwargs) | |
method = <function TerminalIPythonApp.initialize at 0x10378c0d0> | |
app = <IPython.terminal.ipapp.TerminalIPythonApp object at 0x10321fb70> | |
args = (None,) | |
kwargs = {} | |
75 except (TraitError, ArgumentError) as e: | |
76 app.print_help() | |
77 app.log.fatal("Bad config encountered during initialization:") | |
78 app.log.fatal(str(e)) | |
79 app.log.debug("Config at the time: %s", app.config) | |
80 app.exit(1) | |
81 | |
82 | |
83 class ApplicationError(Exception): | |
84 pass | |
85 | |
86 | |
87 class LevelFormatter(logging.Formatter): | |
88 """Formatter with additional `highlevel` record | |
89 | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/terminal/ipapp.py in initialize(self=<IPython.terminal.ipapp.TerminalIPythonApp object>, argv=None) | |
290 | |
291 return super(TerminalIPythonApp, self).parse_command_line(argv) | |
292 | |
293 @catch_config_error | |
294 def initialize(self, argv=None): | |
295 """Do actions after construct, but before starting the app.""" | |
296 super(TerminalIPythonApp, self).initialize(argv) | |
297 if self.subapp is not None: | |
298 # don't bother initializing further, starting subapp | |
299 return | |
300 # print self.extra_args | |
301 if self.extra_args and not self.something_to_run: | |
302 self.file_to_run = self.extra_args[0] | |
303 self.init_path() | |
304 # create the shell | |
--> 305 self.init_shell() | |
self.init_shell = <bound method TerminalIPythonApp.init_shell of <IPython.terminal.ipapp.TerminalIPythonApp object at 0x10321fb70>> | |
306 # and draw the banner | |
307 self.init_banner() | |
308 # Now a variety of things that happen after the banner is printed. | |
309 self.init_gui_pylab() | |
310 self.init_extensions() | |
311 self.init_code() | |
312 | |
313 def init_shell(self): | |
314 """initialize the InteractiveShell instance""" | |
315 # Create an InteractiveShell instance. | |
316 # shell.display_banner should always be False for the terminal | |
317 # based app, because we call shell.show_banner() by hand below | |
318 # so the banner shows *before* all extension loading stuff. | |
319 self.shell = TerminalInteractiveShell.instance(parent=self, | |
320 display_banner=False, profile_dir=self.profile_dir, | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/terminal/ipapp.py in init_shell(self=<IPython.terminal.ipapp.TerminalIPythonApp object>) | |
306 # and draw the banner | |
307 self.init_banner() | |
308 # Now a variety of things that happen after the banner is printed. | |
309 self.init_gui_pylab() | |
310 self.init_extensions() | |
311 self.init_code() | |
312 | |
313 def init_shell(self): | |
314 """initialize the InteractiveShell instance""" | |
315 # Create an InteractiveShell instance. | |
316 # shell.display_banner should always be False for the terminal | |
317 # based app, because we call shell.show_banner() by hand below | |
318 # so the banner shows *before* all extension loading stuff. | |
319 self.shell = TerminalInteractiveShell.instance(parent=self, | |
320 display_banner=False, profile_dir=self.profile_dir, | |
--> 321 ipython_dir=self.ipython_dir, user_ns=self.user_ns) | |
global ipython_dir = undefined | |
self.ipython_dir = '/Users/mattmorrison/.ipython' | |
global user_ns = undefined | |
self.user_ns = None | |
322 self.shell.configurables.append(self) | |
323 | |
324 def init_banner(self): | |
325 """optionally display the banner""" | |
326 if self.display_banner and self.interact: | |
327 self.shell.show_banner() | |
328 # Make sure there is a space below the banner. | |
329 if self.log_level <= logging.INFO: print() | |
330 | |
331 def _pylab_changed(self, name, old, new): | |
332 """Replace --pylab='inline' with --pylab='auto'""" | |
333 if new == 'inline': | |
334 warn.warn("'inline' not available as pylab backend, " | |
335 "using 'auto' instead.") | |
336 self.pylab = 'auto' | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/configurable.py in instance(cls=<class 'IPython.terminal.interactiveshell.TerminalInteractiveShell'>, *args=(), **kwargs={'display_banner': False, 'ipython_dir': '/Users/mattmorrison/.ipython', 'parent': <IPython.terminal.ipapp.TerminalIPythonApp object>, 'profile_dir': <IPython.core.profiledir.ProfileDir object>, 'user_ns': None}) | |
390 >>> class Foo(SingletonConfigurable): pass | |
391 >>> foo = Foo.instance() | |
392 >>> foo == Foo.instance() | |
393 True | |
394 | |
395 Create a subclass that is retrived using the base class instance:: | |
396 | |
397 >>> class Bar(SingletonConfigurable): pass | |
398 >>> class Bam(Bar): pass | |
399 >>> bam = Bam.instance() | |
400 >>> bam == Bar.instance() | |
401 True | |
402 """ | |
403 # Create and save the instance | |
404 if cls._instance is None: | |
--> 405 inst = cls(*args, **kwargs) | |
inst = undefined | |
cls = <class 'IPython.terminal.interactiveshell.TerminalInteractiveShell'> | |
args = () | |
kwargs = {'user_ns': None, 'ipython_dir': '/Users/mattmorrison/.ipython', 'display_banner': False, 'parent': <IPython.terminal.ipapp.TerminalIPythonApp object at 0x10321fb70>, 'profile_dir': <IPython.core.profiledir.ProfileDir object at 0x103788748>} | |
406 # Now make sure that the instance will also be returned by | |
407 # parent classes' _instance attribute. | |
408 for subclass in cls._walk_mro(): | |
409 subclass._instance = inst | |
410 | |
411 if isinstance(cls._instance, cls): | |
412 return cls._instance | |
413 else: | |
414 raise MultipleInstanceError( | |
415 'Multiple incompatible subclass instances of ' | |
416 '%s are being created.' % cls.__name__ | |
417 ) | |
418 | |
419 @classmethod | |
420 def initialized(cls): | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/core/interactiveshell.py in __init__(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, ipython_dir='/Users/mattmorrison/.ipython', profile_dir=<IPython.core.profiledir.ProfileDir object>, user_module=None, user_ns=None, custom_exceptions=((), None), **kwargs={'display_banner': False, 'parent': <IPython.terminal.ipapp.TerminalIPythonApp object>}) | |
486 # raw_input. | |
487 if py3compat.PY3: | |
488 self.raw_input_original = input | |
489 else: | |
490 self.raw_input_original = raw_input | |
491 # init_completer must come after init_readline, because it needs to | |
492 # know whether readline is present or not system-wide to configure the | |
493 # completers, since the completion machinery can now operate | |
494 # independently of readline (e.g. over the network) | |
495 self.init_completer() | |
496 # TODO: init_io() needs to happen before init_traceback handlers | |
497 # because the traceback handlers hardcode the stdout/stderr streams. | |
498 # This logic in in debugger.Pdb and should eventually be changed. | |
499 self.init_io() | |
500 self.init_traceback_handlers(custom_exceptions) | |
--> 501 self.init_prompts() | |
self.init_prompts = <bound method InteractiveShell.init_prompts of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x1037886a0>> | |
502 self.init_display_formatter() | |
503 self.init_display_pub() | |
504 self.init_data_pub() | |
505 self.init_displayhook() | |
506 self.init_magics() | |
507 self.init_alias() | |
508 self.init_logstart() | |
509 self.init_pdb() | |
510 self.init_extension_manager() | |
511 self.init_payload() | |
512 self.init_deprecation_warnings() | |
513 self.hooks.late_startup_hook() | |
514 self.events.trigger('shell_initialized', self) | |
515 atexit.register(self.atexit_operations) | |
516 | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/core/interactiveshell.py in init_prompts(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>) | |
659 'NoColor', | |
660 self.object_info_string_level) | |
661 | |
662 def init_io(self): | |
663 # This will just use sys.stdout and sys.stderr. If you want to | |
664 # override sys.stdout and sys.stderr themselves, you need to do that | |
665 # *before* instantiating this class, because io holds onto | |
666 # references to the underlying streams. | |
667 if (sys.platform == 'win32' or sys.platform == 'cli') and self.has_readline: | |
668 io.stdout = io.stderr = io.IOStream(self.readline._outputfile) | |
669 else: | |
670 io.stdout = io.IOStream(sys.stdout) | |
671 io.stderr = io.IOStream(sys.stderr) | |
672 | |
673 def init_prompts(self): | |
--> 674 self.prompt_manager = PromptManager(shell=self, parent=self) | |
self.prompt_manager = undefined | |
global PromptManager = <class 'IPython.core.prompts.PromptManager'> | |
global shell = undefined | |
self = <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x1037886a0> | |
global parent = undefined | |
675 self.configurables.append(self.prompt_manager) | |
676 # Set system prompts, so that scripts can decide if they are running | |
677 # interactively. | |
678 sys.ps1 = 'In : ' | |
679 sys.ps2 = '...: ' | |
680 sys.ps3 = 'Out: ' | |
681 | |
682 def init_display_formatter(self): | |
683 self.display_formatter = DisplayFormatter(parent=self) | |
684 self.configurables.append(self.display_formatter) | |
685 | |
686 def init_display_pub(self): | |
687 self.display_pub = self.display_pub_class(parent=self) | |
688 self.configurables.append(self.display_pub) | |
689 | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/core/prompts.py in __init__(self=<IPython.core.prompts.PromptManager object>, shell=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, **kwargs={'parent': <IPython.terminal.interactiveshell.TerminalInteractiveShell object>}) | |
285 | |
286 # We actually store the expanded templates here: | |
287 templates = Dict() | |
288 | |
289 # The number of characters in the last prompt rendered, not including | |
290 # colour characters. | |
291 width = Int() | |
292 txtwidth = Int() # Not including right-justification | |
293 | |
294 # The number of characters in each prompt which don't contribute to width | |
295 invisible_chars = Dict() | |
296 def _invisible_chars_default(self): | |
297 return {'in': 0, 'in2': 0, 'out': 0, 'rewrite':0} | |
298 | |
299 def __init__(self, shell, **kwargs): | |
--> 300 super(PromptManager, self).__init__(shell=shell, **kwargs) | |
global super = undefined | |
global PromptManager = <class 'IPython.core.prompts.PromptManager'> | |
self.__init__ = <bound method PromptManager.__init__ of <IPython.core.prompts.PromptManager object at 0x103d9d160>> | |
shell = <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x1037886a0> | |
kwargs = {'parent': <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x1037886a0>} | |
301 | |
302 # Prepare colour scheme table | |
303 self.color_scheme_table = coloransi.ColorSchemeTable([NoColor, | |
304 LinuxColors, LightBGColors], self.color_scheme) | |
305 | |
306 self._formatter = UserNSFormatter(shell) | |
307 # Prepare templates & numbers of invisible characters | |
308 self.update_prompt('in', self.in_template) | |
309 self.update_prompt('in2', self.in2_template) | |
310 self.update_prompt('out', self.out_template) | |
311 self.update_prompt('rewrite') | |
312 self.on_trait_change(self._update_prompt_trait, ['in_template', | |
313 'in2_template', 'out_template']) | |
314 | |
315 def update_prompt(self, name, new_template=None): | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/configurable.py in __init__(self=<IPython.core.prompts.PromptManager object>, **kwargs={'shell': <IPython.terminal.interactiveshell.TerminalInteractiveShell object>}) | |
70 | |
71 config = kwargs.pop('config', None) | |
72 | |
73 # load kwarg traits, other than config | |
74 super(Configurable, self).__init__(**kwargs) | |
75 | |
76 # load config | |
77 if config is not None: | |
78 # We used to deepcopy, but for now we are trying to just save | |
79 # by reference. This *could* have side effects as all components | |
80 # will share config. In fact, I did find such a side effect in | |
81 # _config_changed below. If a config attribute value was a mutable type | |
82 # all instances of a component were getting the same copy, effectively | |
83 # making that a class attribute. | |
84 # self.config = deepcopy(config) | |
---> 85 self.config = config | |
self.config = {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}} | |
config = {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}} | |
86 else: | |
87 # allow _config_default to return something | |
88 self._load_config(self.config) | |
89 | |
90 # Ensure explicit kwargs are applied after loading config. | |
91 # This is usually redundant, but ensures config doesn't override | |
92 # explicitly assigned values. | |
93 for key, value in kwargs.items(): | |
94 setattr(self, key, value) | |
95 | |
96 #------------------------------------------------------------------------- | |
97 # Static trait notifiations | |
98 #------------------------------------------------------------------------- | |
99 | |
100 @classmethod | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in __set__(self=<traitlets.traitlets.Instance object>, obj=<IPython.core.prompts.PromptManager object>, value={'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}) | |
543 silent = False | |
544 if silent is not True: | |
545 # we explicitly compare silent to True just in case the equality | |
546 # comparison above returns something other than True/False | |
547 obj._notify_trait(self.name, old_value, new_value) | |
548 | |
549 def __set__(self, obj, value): | |
550 """Set the value of the trait by self.name for the instance. | |
551 | |
552 Values pass through a validation stage where errors are raised when | |
553 impropper types, or types that cannot be coerced, are encountered. | |
554 """ | |
555 if self.read_only: | |
556 raise TraitError('The "%s" trait is read-only.' % self.name) | |
557 else: | |
--> 558 self.set(obj, value) | |
self.set = <bound method TraitType.set of <traitlets.traitlets.Instance object at 0x102d14e10>> | |
obj = <IPython.core.prompts.PromptManager object at 0x103d9d160> | |
value = {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}} | |
559 | |
560 def _validate(self, obj, value): | |
561 if value is None and self.allow_none: | |
562 return value | |
563 if hasattr(self, 'validate'): | |
564 value = self.validate(obj, value) | |
565 if obj._cross_validation_lock is False: | |
566 value = self._cross_validate(obj, value) | |
567 return value | |
568 | |
569 def _cross_validate(self, obj, value): | |
570 if self.name in obj._trait_validators: | |
571 proposal = {'trait': self, 'value': value, 'owner': obj} | |
572 value = obj._trait_validators[self.name](obj, proposal) | |
573 elif hasattr(obj, '_%s_validate' % self.name): | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in set(self=<traitlets.traitlets.Instance object>, obj=<IPython.core.prompts.PromptManager object>, value={'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}) | |
532 new_value = self._validate(obj, value) | |
533 try: | |
534 old_value = obj._trait_values[self.name] | |
535 except KeyError: | |
536 old_value = self.default_value | |
537 | |
538 obj._trait_values[self.name] = new_value | |
539 try: | |
540 silent = bool(old_value == new_value) | |
541 except: | |
542 # if there is an error in comparing, default to notify | |
543 silent = False | |
544 if silent is not True: | |
545 # we explicitly compare silent to True just in case the equality | |
546 # comparison above returns something other than True/False | |
--> 547 obj._notify_trait(self.name, old_value, new_value) | |
obj._notify_trait = <bound method HasTraits._notify_trait of <IPython.core.prompts.PromptManager object at 0x103d9d160>> | |
self.name = 'config' | |
old_value = traitlets.Undefined | |
new_value = {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}} | |
548 | |
549 def __set__(self, obj, value): | |
550 """Set the value of the trait by self.name for the instance. | |
551 | |
552 Values pass through a validation stage where errors are raised when | |
553 impropper types, or types that cannot be coerced, are encountered. | |
554 """ | |
555 if self.read_only: | |
556 raise TraitError('The "%s" trait is read-only.' % self.name) | |
557 else: | |
558 self.set(obj, value) | |
559 | |
560 def _validate(self, obj, value): | |
561 if value is None and self.allow_none: | |
562 return value | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in _notify_trait(self=<IPython.core.prompts.PromptManager object>, name='config', old_value=traitlets.Undefined, new_value={'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}) | |
1078 # Presence of the notify_change method | |
1079 # on __dict__ can cause memory leaks | |
1080 # and prevents pickleability | |
1081 self.__dict__.pop('notify_change') | |
1082 # trigger delayed notifications | |
1083 for changes in cache.values(): | |
1084 for change in changes: | |
1085 self.notify_change(change) | |
1086 | |
1087 def _notify_trait(self, name, old_value, new_value): | |
1088 self.notify_change({ | |
1089 'name': name, | |
1090 'old': old_value, | |
1091 'new': new_value, | |
1092 'owner': self, | |
-> 1093 'type': 'change', | |
1094 }) | |
1095 | |
1096 def notify_change(self, change): | |
1097 name, type = change['name'], change['type'] | |
1098 | |
1099 callables = [] | |
1100 callables.extend(self._trait_notifiers.get(name, {}).get(type, [])) | |
1101 callables.extend(self._trait_notifiers.get(name, {}).get(All, [])) | |
1102 callables.extend(self._trait_notifiers.get(All, {}).get(type, [])) | |
1103 callables.extend(self._trait_notifiers.get(All, {}).get(All, [])) | |
1104 | |
1105 # Now static ones | |
1106 magic_name = '_%s_changed' % name | |
1107 if hasattr(self, magic_name): | |
1108 class_value = getattr(self.__class__, magic_name) | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in notify_change(self=<IPython.core.prompts.PromptManager object>, change={'name': 'config', 'new': {'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}, 'old': traitlets.Undefined, 'owner': <IPython.core.prompts.PromptManager object>, 'type': 'change'}) | |
1112 cb = getattr(self, magic_name) | |
1113 # Only append the magic method if it was not manually registered | |
1114 if cb not in callables: | |
1115 callables.append(_callback_wrapper(cb)) | |
1116 | |
1117 # Call them all now | |
1118 # Traits catches and logs errors here. I allow them to raise | |
1119 for c in callables: | |
1120 # Bound methods have an additional 'self' argument. | |
1121 | |
1122 if isinstance(c, _CallbackWrapper): | |
1123 c = c.__call__ | |
1124 elif isinstance(c, EventHandler) and c.name is not None: | |
1125 c = getattr(self, c.name) | |
1126 | |
-> 1127 c(change) | |
c = <bound method observe_compat.<locals>.compatible_observer of <IPython.core.prompts.PromptManager object at 0x103d9d160>> | |
change = {'name': 'config', 'owner': <IPython.core.prompts.PromptManager object at 0x103d9d160>, 'new': {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}}, 'type': 'change', 'old': traitlets.Undefined} | |
1128 | |
1129 def _add_notifiers(self, handler, name, type): | |
1130 if name not in self._trait_notifiers: | |
1131 nlist = [] | |
1132 self._trait_notifiers[name] = {type: nlist} | |
1133 else: | |
1134 if type not in self._trait_notifiers[name]: | |
1135 nlist = [] | |
1136 self._trait_notifiers[name][type] = nlist | |
1137 else: | |
1138 nlist = self._trait_notifiers[name][type] | |
1139 if handler not in nlist: | |
1140 nlist.append(handler) | |
1141 | |
1142 def _remove_notifiers(self, handler, name, type): | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in compatible_observer(self=<IPython.core.prompts.PromptManager object>, change_or_name={'name': 'config', 'new': {'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}, 'old': traitlets.Undefined, 'owner': <IPython.core.prompts.PromptManager object>, 'type': 'change'}, old=traitlets.Undefined, new=traitlets.Undefined) | |
763 """ | |
764 def compatible_observer(self, change_or_name, old=Undefined, new=Undefined): | |
765 if isinstance(change_or_name, dict): | |
766 change = change_or_name | |
767 else: | |
768 clsname = self.__class__.__name__ | |
769 warn("A parent of %s._%s_changed has adopted the new @observe(change) API" % ( | |
770 clsname, change_or_name), DeprecationWarning) | |
771 change = { | |
772 'type': 'change', | |
773 'old': old, | |
774 'new': new, | |
775 'name': change_or_name, | |
776 'owner': self, | |
777 } | |
--> 778 return func(self, change) | |
global func = undefined | |
self = <IPython.core.prompts.PromptManager object at 0x103d9d160> | |
change = {'name': 'config', 'owner': <IPython.core.prompts.PromptManager object at 0x103d9d160>, 'new': {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}}, 'type': 'change', 'old': traitlets.Undefined} | |
779 return compatible_observer | |
780 | |
781 | |
782 def validate(*names): | |
783 """A decorator to register cross validator of HasTraits object's state | |
784 when a Trait is set. | |
785 | |
786 The handler passed to the decorator must have one ``proposal`` dict argument. | |
787 The proposal dictionary must hold the following keys: | |
788 * ``owner`` : the HasTraits instance | |
789 * ``value`` : the proposed value for the modified trait attribute | |
790 * ``trait`` : the TraitType instance associated with the attribute | |
791 | |
792 Parameters | |
793 ---------- | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/configurable.py in _config_changed(self=<IPython.core.prompts.PromptManager object>, change={'name': 'config', 'new': {'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}, 'old': traitlets.Undefined, 'owner': <IPython.core.prompts.PromptManager object>, 'type': 'change'}) | |
172 @observe_compat | |
173 def _config_changed(self, change): | |
174 """Update all the class traits having ``config=True`` in metadata. | |
175 | |
176 For any class trait with a ``config`` metadata attribute that is | |
177 ``True``, we update the trait with the value of the corresponding | |
178 config entry. | |
179 """ | |
180 # Get all traits with a config metadata entry that is True | |
181 traits = self.traits(config=True) | |
182 | |
183 # We auto-load config section for this class as well as any parent | |
184 # classes that are Configurable subclasses. This starts with Configurable | |
185 # and works down the mro loading the config for each section. | |
186 section_names = self.section_names() | |
--> 187 self._load_config(change['new'], traits=traits, section_names=section_names) | |
self._load_config = <bound method Configurable._load_config of <IPython.core.prompts.PromptManager object at 0x103d9d160>> | |
change = {'name': 'config', 'owner': <IPython.core.prompts.PromptManager object at 0x103d9d160>, 'new': {'InteractiveShellApp': {'gui': 'osx', 'exec_lines': ['import numpy as np', 'import pandas as pd', 'from pandas import Series, DataFrame', 'import matplotlib as mpl', 'from pprint import pprint as pp', 'def fixquote(): print(\'"\'*3)'], 'pylab_import_all': False, 'pylab': 'osx'}, 'TerminalInteractiveShell': {'confirm_exit': False, 'autoindent': True, 'editor': 'subl -w', 'colors': 'NoColor'}, 'PlainTextFormatter': {'pprint': False}, 'IPCompleter': {'limit_to__all__': False, 'omit__names': 0}, 'TerminalIPythonApp': {'gui': 'osx', 'pylab': 'osx', 'verbose_crash': True}, 'PromptManager': {'color_scheme': 'NoColor'}}, 'type': 'change', 'old': traitlets.Undefined} | |
traits = {'color_scheme': <traitlets.traitlets.Unicode object at 0x103549f98>, 'in2_template': <traitlets.traitlets.Unicode object at 0x1035460f0>, 'out_template': <traitlets.traitlets.Unicode object at 0x103546128>, 'justify': <traitlets.traitlets.Bool object at 0x103546160>, 'in_template': <traitlets.traitlets.Unicode object at 0x1035460b8>} | |
section_names = ['Configurable', 'PromptManager'] | |
188 | |
189 def update_config(self, config): | |
190 """Update config and load the new values""" | |
191 # load config | |
192 self._load_config(config) | |
193 # merge it into self.config | |
194 self.config.merge(config) | |
195 # TODO: trigger change event if/when dict-update change events take place | |
196 # DO NOT trigger full trait-change | |
197 | |
198 @classmethod | |
199 def class_get_help(cls, inst=None): | |
200 """Get the help string for this class in ReST format. | |
201 | |
202 If `inst` is given, it's current trait values will be used in place of | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/config/configurable.py in _load_config(self=<IPython.core.prompts.PromptManager object>, cfg={'InteractiveShellApp': {'gui': 'osx', 'exec_lin...e}, 'PromptManager': {'color_scheme': 'NoColor'}}, section_names=['Configurable', 'PromptManager'], traits={'color_scheme': <traitlets.traitlets.Unicode object>, 'in2_template': <traitlets.traitlets.Unicode object>, 'in_template': <traitlets.traitlets.Unicode object>, 'justify': <traitlets.traitlets.Bool object>, 'out_template': <traitlets.traitlets.Unicode object>}) | |
154 setattr(self, name, deepcopy(config_value)) | |
155 elif not _is_section_key(name) and not isinstance(config_value, Config): | |
156 from difflib import get_close_matches | |
157 if isinstance(self, LoggingConfigurable): | |
158 warn = self.log.warning | |
159 else: | |
160 warn = lambda msg: warnings.warn(msg, stacklevel=9) | |
161 matches = get_close_matches(name, traits) | |
162 msg = u"Config option `{option}` not recognized by `{klass}`.".format( | |
163 option=name, klass=self.__class__.__name__) | |
164 | |
165 if len(matches) == 1: | |
166 msg += u" Did you mean `{matches}`?".format(matches=matches[0]) | |
167 elif len(matches) >= 1: | |
168 msg +=" Did you mean one of: `{matches}`?".format(matches=', '.join(sorted(matches))) | |
--> 169 warn(msg) | |
warn = undefined | |
msg = undefined | |
170 | |
171 @observe('config') | |
172 @observe_compat | |
173 def _config_changed(self, change): | |
174 """Update all the class traits having ``config=True`` in metadata. | |
175 | |
176 For any class trait with a ``config`` metadata attribute that is | |
177 ``True``, we update the trait with the value of the corresponding | |
178 config entry. | |
179 """ | |
180 # Get all traits with a config metadata entry that is True | |
181 traits = self.traits(config=True) | |
182 | |
183 # We auto-load config section for this class as well as any parent | |
184 # classes that are Configurable subclasses. This starts with Configurable | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py in __exit__(self=<contextlib._GeneratorContextManager object>, type=None, value=None, traceback=None) | |
51 def _recreate_cm(self): | |
52 # _GCM instances are one-shot context managers, so the | |
53 # CM must be recreated each time a decorated function is | |
54 # called | |
55 return self.__class__(self.func, self.args, self.kwds) | |
56 | |
57 def __enter__(self): | |
58 try: | |
59 return next(self.gen) | |
60 except StopIteration: | |
61 raise RuntimeError("generator didn't yield") from None | |
62 | |
63 def __exit__(self, type, value, traceback): | |
64 if type is None: | |
65 try: | |
---> 66 next(self.gen) | |
global next = undefined | |
self.gen = <generator object hold_trait_notifications at 0x10381a830> | |
67 except StopIteration: | |
68 return | |
69 else: | |
70 raise RuntimeError("generator didn't stop") | |
71 else: | |
72 if value is None: | |
73 # Need to force instantiation so we can reliably | |
74 # tell if we get the same exception back | |
75 value = type() | |
76 try: | |
77 self.gen.throw(type, value, traceback) | |
78 raise RuntimeError("generator didn't stop after throw()") | |
79 except StopIteration as exc: | |
80 # Suppress StopIteration *unless* it's the same exception that | |
81 # was passed to throw(). This prevents a StopIteration | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in hold_trait_notifications(self=<IPython.core.prompts.PromptManager object>) | |
1070 raise e | |
1071 finally: | |
1072 # Reset the notify_change to original value, enable cross-validation | |
1073 # and fire resulting change notifications. | |
1074 self.notify_change = notify_change | |
1075 self._cross_validation_lock = False | |
1076 | |
1077 if isinstance(notify_change, types.MethodType): | |
1078 # Presence of the notify_change method | |
1079 # on __dict__ can cause memory leaks | |
1080 # and prevents pickleability | |
1081 self.__dict__.pop('notify_change') | |
1082 # trigger delayed notifications | |
1083 for changes in cache.values(): | |
1084 for change in changes: | |
-> 1085 self.notify_change(change) | |
self.notify_change = <bound method HasTraits.notify_change of <IPython.core.prompts.PromptManager object at 0x103d9d160>> | |
change = {'name': 'color_scheme', 'owner': <IPython.core.prompts.PromptManager object at 0x103d9d160>, 'new': 'NoColor', 'type': 'change', 'old': 'Linux'} | |
1086 | |
1087 def _notify_trait(self, name, old_value, new_value): | |
1088 self.notify_change({ | |
1089 'name': name, | |
1090 'old': old_value, | |
1091 'new': new_value, | |
1092 'owner': self, | |
1093 'type': 'change', | |
1094 }) | |
1095 | |
1096 def notify_change(self, change): | |
1097 name, type = change['name'], change['type'] | |
1098 | |
1099 callables = [] | |
1100 callables.extend(self._trait_notifiers.get(name, {}).get(type, [])) | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in notify_change(self=<IPython.core.prompts.PromptManager object>, change={'name': 'color_scheme', 'new': 'NoColor', 'old': 'Linux', 'owner': <IPython.core.prompts.PromptManager object>, 'type': 'change'}) | |
1112 cb = getattr(self, magic_name) | |
1113 # Only append the magic method if it was not manually registered | |
1114 if cb not in callables: | |
1115 callables.append(_callback_wrapper(cb)) | |
1116 | |
1117 # Call them all now | |
1118 # Traits catches and logs errors here. I allow them to raise | |
1119 for c in callables: | |
1120 # Bound methods have an additional 'self' argument. | |
1121 | |
1122 if isinstance(c, _CallbackWrapper): | |
1123 c = c.__call__ | |
1124 elif isinstance(c, EventHandler) and c.name is not None: | |
1125 c = getattr(self, c.name) | |
1126 | |
-> 1127 c(change) | |
c = <bound method _CallbackWrapper.__call__ of <traitlets.traitlets._CallbackWrapper object at 0x103d9d3c8>> | |
change = {'name': 'color_scheme', 'owner': <IPython.core.prompts.PromptManager object at 0x103d9d160>, 'new': 'NoColor', 'type': 'change', 'old': 'Linux'} | |
1128 | |
1129 def _add_notifiers(self, handler, name, type): | |
1130 if name not in self._trait_notifiers: | |
1131 nlist = [] | |
1132 self._trait_notifiers[name] = {type: nlist} | |
1133 else: | |
1134 if type not in self._trait_notifiers[name]: | |
1135 nlist = [] | |
1136 self._trait_notifiers[name][type] = nlist | |
1137 else: | |
1138 nlist = self._trait_notifiers[name][type] | |
1139 if handler not in nlist: | |
1140 nlist.append(handler) | |
1141 | |
1142 def _remove_notifiers(self, handler, name, type): | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/traitlets/traitlets.py in __call__(self=<traitlets.traitlets._CallbackWrapper object>, change={'name': 'color_scheme', 'new': 'NoColor', 'old': 'Linux', 'owner': <IPython.core.prompts.PromptManager object>, 'type': 'change'}) | |
655 | |
656 def __eq__(self, other): | |
657 # The wrapper is equal to the wrapped element | |
658 if isinstance(other, _CallbackWrapper): | |
659 return self.cb == other.cb | |
660 else: | |
661 return self.cb == other | |
662 | |
663 def __call__(self, change): | |
664 # The wrapper is callable | |
665 if self.nargs == 0: | |
666 self.cb() | |
667 elif self.nargs == 1: | |
668 self.cb(change['name']) | |
669 elif self.nargs == 2: | |
--> 670 self.cb(change['name'], change['new']) | |
self.cb = <bound method PromptManager._color_scheme_changed of <IPython.core.prompts.PromptManager object at 0x103d9d160>> | |
change = {'name': 'color_scheme', 'owner': <IPython.core.prompts.PromptManager object at 0x103d9d160>, 'new': 'NoColor', 'type': 'change', 'old': 'Linux'} | |
671 elif self.nargs == 3: | |
672 self.cb(change['name'], change['old'], change['new']) | |
673 elif self.nargs == 4: | |
674 self.cb(change['name'], change['old'], change['new'], change['owner']) | |
675 | |
676 def _callback_wrapper(cb): | |
677 if isinstance(cb, _CallbackWrapper): | |
678 return cb | |
679 else: | |
680 return _CallbackWrapper(cb) | |
681 | |
682 | |
683 class MetaHasDescriptors(type): | |
684 """A metaclass for HasDescriptors. | |
685 | |
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/core/prompts.py in _color_scheme_changed(self=<IPython.core.prompts.PromptManager object>, name='color_scheme', new_value='NoColor') | |
246 # next, look in user_ns and builtins: | |
247 for container in (self.shell.user_ns, __builtins__): | |
248 if key in container: | |
249 return container[key] | |
250 # nothing found, put error message in its place | |
251 return "<ERROR: '%s' not found>" % key | |
252 | |
253 | |
254 class PromptManager(Configurable): | |
255 """This is the primary interface for producing IPython's prompts.""" | |
256 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | |
257 | |
258 color_scheme_table = Instance(coloransi.ColorSchemeTable, allow_none=True) | |
259 color_scheme = Unicode('Linux', config=True) | |
260 def _color_scheme_changed(self, name, new_value): | |
--> 261 self.color_scheme_table.set_active_scheme(new_value) | |
self.color_scheme_table.set_active_scheme = undefined | |
new_value = 'NoColor' | |
262 for pname in ['in', 'in2', 'out', 'rewrite']: | |
263 # We need to recalculate the number of invisible characters | |
264 self.update_prompt(pname) | |
265 | |
266 lazy_evaluate_fields = Dict(help=""" | |
267 This maps field names used in the prompt templates to functions which | |
268 will be called when the prompt is rendered. This allows us to include | |
269 things like the current time in the prompts. Functions are only called | |
270 if they are used in the prompt. | |
271 """) | |
272 def _lazy_evaluate_fields_default(self): return lazily_evaluate.copy() | |
273 | |
274 in_template = Unicode('In [\\#]: ', config=True, | |
275 help="Input prompt. '\\#' will be transformed to the prompt number") | |
276 in2_template = Unicode(' .\\D.: ', config=True, | |
AttributeError: 'NoneType' object has no attribute 'set_active_scheme' | |
*************************************************************************** | |
History of session input: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment