From a889460a436b646af0ab60b952b0bb74bd079a3b 2014-11-01 23:41:02 From: MinRK Date: 2014-11-01 23:41:02 Subject: [PATCH] preserve orig_nbformat when converting 3 to 4 preserves orig_nbformat = 2 in 2->3->4 --- diff --git a/IPython/nbformat/v4/convert.py b/IPython/nbformat/v4/convert.py index 257f6ef..cbd1e3b 100644 --- a/IPython/nbformat/v4/convert.py +++ b/IPython/nbformat/v4/convert.py @@ -34,9 +34,10 @@ def upgrade(nb, from_version=3, from_minor=0): except ValidationError as e: get_logger().error("Notebook JSON is not valid v%i: %s", from_version, e) - # Mark the original nbformat so consumers know it has been converted. - nb.pop('orig_nbformat', None) - nb.metadata.orig_nbformat = 3 + # Mark the original nbformat so consumers know it has been converted + orig_nbformat = nb.pop('orig_nbformat', None) + nb.metadata.orig_nbformat = orig_nbformat or 3 + # Mark the new format nb.nbformat = nbformat nb.nbformat_minor = nbformat_minor