From e1170582fa7c8e3096f3acb6b6deea4b0a247cf2 2014-11-03 19:46:39 From: Min RK Date: 2014-11-03 19:46:39 Subject: [PATCH] Set orig_nbformat keys when downgrading v4->v3 --- diff --git a/IPython/nbformat/v4/convert.py b/IPython/nbformat/v4/convert.py index 37e5330..24bf53e 100644 --- a/IPython/nbformat/v4/convert.py +++ b/IPython/nbformat/v4/convert.py @@ -241,9 +241,11 @@ def downgrade(nb): cells = [ downgrade_cell(cell) for cell in nb.pop('cells') ] nb.worksheets = [v3.new_worksheet(cells=cells)] nb.metadata.setdefault('name', '') - nb.metadata.pop('orig_nbformat', None) - nb.metadata.pop('orig_nbformat_minor', None) - + # Validate the converted notebook before returning it _warn_if_invalid(nb, v3.nbformat) + + nb.orig_nbformat = nb.metadata.pop('orig_nbformat', nbformat) + nb.orig_nbformat_minor = nb.metadata.pop('orig_nbformat_minor', nbformat_minor) + return nb