about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch')
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch
new file mode 100644
index 000000000000..83bd83a6d33b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch
@@ -0,0 +1,36 @@
+diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
+index cb3667659e..867f547d71 100644
+--- a/src/sage/doctest/forker.py
++++ b/src/sage/doctest/forker.py
+@@ -200,6 +200,15 @@ def init_sage(controller=None):
+     from sage.cpython._py2_random import Random
+     sage.misc.randstate.DEFAULT_PYTHON_RANDOM = Random
+ 
++    # IPython's pretty printer sorts the repr of dicts by their keys by default
++    # (or their keys' str() if they are not otherwise orderable).  However, it
++    # disables this for CPython 3.6+ opting to instead display dicts' "natural"
++    # insertion order, which is preserved in those versions).
++    # However, this order is random in some instances.
++    # Also modifications of code may affect the order.
++    # So here we fore sorted dict printing.
++    IPython.lib.pretty.for_type(dict, _sorted_dict_pprinter_factory('{', '}'))
++
+     if controller is None:
+         import sage.repl.ipython_kernel.all_jupyter
+     else:
+@@ -222,15 +231,6 @@ def init_sage(controller=None):
+     from sage.repl.rich_output.backend_doctest import BackendDoctest
+     dm.switch_backend(BackendDoctest())
+ 
+-    # IPython's pretty printer sorts the repr of dicts by their keys by default
+-    # (or their keys' str() if they are not otherwise orderable).  However, it
+-    # disables this for CPython 3.6+ opting to instead display dicts' "natural"
+-    # insertion order, which is preserved in those versions).
+-    # However, this order is random in some instances.
+-    # Also modifications of code may affect the order.
+-    # So here we fore sorted dict printing.
+-    IPython.lib.pretty.for_type(dict, _sorted_dict_pprinter_factory('{', '}'))
+-
+     # Switch on extra debugging
+     from sage.structure.debug_options import debug
+     debug.refine_category_hash_check = True