Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
70effc79
Commit
70effc79
authored
Mar 29, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patches/python: fix linecache for python scripts on py3
parent
a61a5518
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
11 deletions
+34
-11
product/ERP5Type/patches/python.py
product/ERP5Type/patches/python.py
+34
-11
No files found.
product/ERP5Type/patches/python.py
View file @
70effc79
...
@@ -143,8 +143,7 @@ def patch_linecache():
...
@@ -143,8 +143,7 @@ def patch_linecache():
if
module_globals
is
None
:
if
module_globals
is
None
:
module_globals
=
get_globals
(
sys
.
_getframe
(
1
))
module_globals
=
get_globals
(
sys
.
_getframe
(
1
))
# Get source code of ZODB Components following PEP 302, when
# Get source code of ZODB Components following PEP 302
# cache is not pre-filled by lazycache.
if
(
filename
.
startswith
(
'<portal_components/'
)
and
if
(
filename
.
startswith
(
'<portal_components/'
)
and
module_globals
is
not
None
):
module_globals
is
not
None
):
data
=
None
data
=
None
...
@@ -158,15 +157,16 @@ def patch_linecache():
...
@@ -158,15 +157,16 @@ def patch_linecache():
pass
pass
return
data
.
splitlines
(
True
)
if
data
is
not
None
else
()
return
data
.
splitlines
(
True
)
if
data
is
not
None
else
()
# in-ZODB python scripts
if
module_globals
is
not
None
:
if
basename
(
filename
)
in
(
'Script (Python)'
,
'ERP5 Python Script'
,
'ERP5 Workflow Script'
):
# in-ZODB python scripts
try
:
if
basename
(
filename
)
in
(
'Script (Python)'
,
'ERP5 Python Script'
,
'ERP5 Workflow Script'
):
script
=
module_globals
[
'script'
]
try
:
if
script
.
_p_jar
.
opened
:
script
=
module_globals
[
'script'
]
return
script
.
body
().
splitlines
(
True
)
if
script
.
_p_jar
.
opened
:
except
Exception
:
return
script
.
body
().
splitlines
(
True
)
pass
except
Exception
:
return
()
pass
return
()
# TALES expressions
# TALES expressions
x
=
expr_search
(
filename
)
x
=
expr_search
(
filename
)
...
@@ -190,6 +190,29 @@ def patch_linecache():
...
@@ -190,6 +190,29 @@ def patch_linecache():
# reconsider), for now, we add an arbitrary prefix for cache.
# reconsider), for now, we add an arbitrary prefix for cache.
if
(
filename
.
startswith
(
'<'
)
and
filename
.
endswith
(
'>'
)):
if
(
filename
.
startswith
(
'<'
)
and
filename
.
endswith
(
'>'
)):
filename
=
'erp5-linecache://'
+
filename
filename
=
'erp5-linecache://'
+
filename
# For python scripts, insert a fake PEP302 loader so that
# linecache can find the source code
if
basename
(
filename
)
in
(
'Script (Python)'
,
'ERP5 Python Script'
,
'ERP5 Workflow Script'
,
)
and
module_globals
is
not
None
:
script
=
module_globals
[
'script'
]
body
=
''
if
script
.
_p_jar
is
None
or
script
.
_p_jar
.
opened
:
body
=
script
.
body
()
class
PythonScriptLoader
:
def
__init__
(
self
,
filename
,
body
):
self
.
filename
=
filename
self
.
body
=
body
def
get_source
(
self
,
name
,
*
args
,
**
kw
):
return
self
.
body
assert
'__loader___'
not
in
module_globals
module_globals
[
'__loader__'
]
=
PythonScriptLoader
(
filename
,
body
)
return
linecache_lazycache
(
filename
,
module_globals
)
return
linecache_lazycache
(
filename
,
module_globals
)
linecache
.
lazycache
=
lazycache
linecache
.
lazycache
=
lazycache
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment