diff --git a/IPython/core/payload.py b/IPython/core/payload.py index 429e005..c95fcdb 100644 --- a/IPython/core/payload.py +++ b/IPython/core/payload.py @@ -29,11 +29,17 @@ class PayloadManager(Configurable): _payload = List([]) - def write_payload(self, data, update=False): + def write_payload(self, data, single=True): + """Include or update the specified `data` payload in the PayloadManager. + + If a previous payload with the same source than `data` exists + and `single` is True, it will be overwritten with the new one. + """ + if not isinstance(data, dict): raise TypeError('Each payload write must be a dict, got: %r' % data) - if update and 'source' in data: + if single and 'source' in data: source = data['source'] for i, pl in enumerate(self._payload): if 'source' in pl and pl['source'] == source: diff --git a/IPython/kernel/zmq/zmqshell.py b/IPython/kernel/zmq/zmqshell.py index 62d2cb8..df7f5a5 100644 --- a/IPython/kernel/zmq/zmqshell.py +++ b/IPython/kernel/zmq/zmqshell.py @@ -583,7 +583,7 @@ class ZMQInteractiveShell(InteractiveShell): source='set_next_input', text=text ) - self.payload_manager.write_payload(payload, update=True) + self.payload_manager.write_payload(payload) #------------------------------------------------------------------------- # Things related to magics