From c7cf6f554644d994a274567b5995b2886c2e3ea5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 7 Apr 2016 06:19:36 +0000
Subject: [PATCH] linecache: add support for ipython >= 3

---
 product/ERP5Type/patches/python.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/product/ERP5Type/patches/python.py b/product/ERP5Type/patches/python.py
index 43d6435ad7..cb165841cb 100644
--- a/product/ERP5Type/patches/python.py
+++ b/product/ERP5Type/patches/python.py
@@ -107,6 +107,14 @@ def patch_linecache():
     if isinstance(m, str) and 'linecache' in m:
       frame = frame.f_back
       m = frame.f_globals['__name__']
+    if m == 'IPython.utils.ulinecache':
+      frame = frame.f_back
+      m = frame.f_globals['__name__']
+      # IPython.utils.ulinecache.getline (used in `list` pdb command) call IPython.utils.ulinecache.getlines
+      # so we may have two frames in IPython.utils.ulinecache module
+      if m == 'IPython.utils.ulinecache':
+        frame = frame.f_back
+        m = frame.f_globals['__name__']
     if m == 'IPython.core.debugger':
       co_name = frame.f_code.co_name
       if co_name == 'format_stack_entry':
-- 
2.30.9