Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
b9f598ce by Mark Sapiro at 2023-02-03T23:46:18+00:00
Fix mailman shell to work with iPython >= 8.0 and display banner.

Fixes #1062

* Fix mailman shell to work with iPython >= 8.0 and display banner.

- - - - -
ef7616d1 by Mark Sapiro at 2023-02-03T23:46:18+00:00
Merge branch 'ipython' into 'master'

Fix mailman shell to work with iPython >= 8.0 and display banner.

Closes #1062

See merge request mailman/mailman!1098

Merged-by: Mark Sapiro <m...@msapiro.net>

Reviewed-by: 
- - - - -


3 changed files:

- src/mailman/commands/cli_withlist.py
- src/mailman/commands/tests/test_cli_shell.py
- src/mailman/docs/NEWS.rst


Changes:

=====================================
src/mailman/commands/cli_withlist.py
=====================================
@@ -22,7 +22,6 @@ import sys
 import click
 
 from contextlib import ExitStack, suppress
-from functools import partial
 from lazr.config import as_boolean
 from mailman.config import config
 from mailman.core.i18n import _
@@ -57,12 +56,11 @@ def start_ipython1(overrides, banner, *, debug=False):
 def start_ipython4(overrides, banner, *, debug=False):
     try:
         from IPython.terminal.embed import InteractiveShellEmbed
-        shell = InteractiveShellEmbed.instance()
     except ImportError:
         if debug:
             print_exc()
         return None
-    return partial(shell.mainloop, local_ns=overrides, display_banner=banner)
+    return InteractiveShellEmbed.instance(banner1=banner, user_ns=overrides)
 
 
 def start_ipython(overrides, banner, debug):


=====================================
src/mailman/commands/tests/test_cli_shell.py
=====================================
@@ -79,9 +79,9 @@ class TestShell(unittest.TestCase):
         mock = MagicMock()
         with hacked_sys_modules('IPython.terminal.embed', mock):
             self._command.invoke(shell, ('--interactive',))
-        posargs, kws = mock.InteractiveShellEmbed.instance().mainloop.call_args
+        posargs, kws = mock.InteractiveShellEmbed.instance.call_args
         self.assertEqual(
-            kws['display_banner'], """Welcome to the GNU Mailman shell
+            kws['banner1'], """Welcome to the GNU Mailman shell
 Use commit() to commit changes.
 Use abort() to discard changes since the last commit.
 Exit with ctrl+D does an implicit commit() but exit() does not.\n""")
@@ -103,9 +103,9 @@ Exit with ctrl+D does an implicit commit() but exit() does 
not.\n""")
         mock = MagicMock()
         with hacked_sys_modules('IPython.terminal.embed', mock):
             self._command.invoke(shell, ('--interactive',))
-        posargs, kws = mock.InteractiveShellEmbed.instance().mainloop.call_args
+        posargs, kws = mock.InteractiveShellEmbed.instance.call_args
         self.assertEqual(
-            kws['display_banner'], """Welcome to the GNU Mailman shell
+            kws['banner1'], """Welcome to the GNU Mailman shell
 Use commit() to commit changes.
 Use abort() to discard changes since the last commit.
 Exit with ctrl+D does an implicit commit() but exit() does not.\n""")


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -30,6 +30,8 @@ Bugs fixed
   postmap_command: no longer throws an exception.  (Closes #1058)
 * When bounce processing disables delivery for a user, the user's score is
   reset so it will be zero if delivery is enabled.  (Closes #1061)
+* The ``mailman shell`` command now works and displays the banner with
+  ``use_ipython: yes``.  (Closes #1062)
 
 .. _news-3.3.8:
 



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/37432e6b9a6f05b34145e0ab23a019f6a1f80011...ef7616d17a63fd33f65e9c8cf1991b0a2f92848c

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/37432e6b9a6f05b34145e0ab23a019f6a1f80011...ef7616d17a63fd33f65e9c8cf1991b0a2f92848c
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to