From c7aea08fe305f667e101fbde50cd3be5aec57fa1 2023-11-24 09:33:48
From: Matthias Bussonnier <bussonniermatthias@gmail.com>
Date: 2023-11-24 09:33:48
Subject: [PATCH] Fix pickleshare warning on completion (#14252)

A better way woudl be to try to use the shelves module ?
---

diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py
index 5e59c6a..29ddab1 100644
--- a/IPython/core/completerlib.py
+++ b/IPython/core/completerlib.py
@@ -117,7 +117,10 @@ def get_root_modules():
         # Don't try to scan for modules every time.
         return list(sys.builtin_module_names)
 
-    rootmodules_cache = ip.db.get('rootmodules_cache', {})
+    if getattr(ip.db, "_mock", False):
+        rootmodules_cache = {}
+    else:
+        rootmodules_cache = ip.db.get("rootmodules_cache", {})
     rootmodules = list(sys.builtin_module_names)
     start_time = time()
     store = False
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index 0a528c5..6772740 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -42,6 +42,8 @@ try:
 except ModuleNotFoundError:
 
     class PickleShareDB:  # type: ignore [no-redef]
+        _mock = True
+
         def __init__(self, path):
             pass