diff --git a/product/ERP5Type/patches/python.py b/product/ERP5Type/patches/python.py
index 46ce9a6a6e0be59944e22edb50be182be25bd814..43d6435ad7245dd5f4113b28dd95ed9d68407bdc 100644
--- a/product/ERP5Type/patches/python.py
+++ b/product/ERP5Type/patches/python.py
@@ -102,7 +102,9 @@ def patch_linecache():
     ipdb does not pass module_globals to getlines()...
     """
     m = frame.f_globals['__name__']
-    if m == 'linecache':
+    # 'linecache' or 'IPython.utils.ulinecache' (may be renamed/moved in
+    # IPython so just check the presence of 'linecache'...)
+    if isinstance(m, str) and 'linecache' in m:
       frame = frame.f_back
       m = frame.f_globals['__name__']
     if m == 'IPython.core.debugger':