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
93ebf837
Commit
93ebf837
authored
Mar 28, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patches/python: update linecache patch for python3
patches/python: fix linecache for python scripts on py3
parent
10ada175
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
9 deletions
+52
-9
product/ERP5Type/patches/python.py
product/ERP5Type/patches/python.py
+52
-9
No files found.
product/ERP5Type/patches/python.py
View file @
93ebf837
...
...
@@ -155,9 +155,10 @@ def patch_linecache():
data
=
get_source
(
name
)
except
(
ImportError
,
AttributeError
):
pass
return
data
.
splitlines
(
True
)
if
data
is
not
None
else
()
if
module_globals
is
not
None
:
# in-ZODB python scripts
if
basename
(
filename
)
in
(
'Script (Python)'
,
'ERP5 Python Script'
,
'ERP5 Workflow Script'
):
try
:
script
=
module_globals
[
'script'
]
...
...
@@ -166,13 +167,55 @@ def patch_linecache():
except
Exception
:
pass
return
()
# TALES expressions
x
=
expr_search
(
filename
)
if
x
:
return
x
.
groups
()
if
filename
.
startswith
(
'<portal_components/'
):
# use our special key for lazycache
filename
=
'erp5-linecache://'
+
filename
return
linecache_getlines
(
filename
,
module_globals
)
linecache
.
getlines
=
getlines
if
sys
.
version_info
[:
3
]
>=
(
3
,
):
linecache_lazycache
=
linecache
.
lazycache
def
lazycache
(
filename
,
module_globals
):
if
filename
:
# XXX linecache ignores files named like <this>, but this is
# what we used for portal_components filename (and it's not so
# good because it's not easy to copy paste, so we might want to
# reconsider), for now, we add an arbitrary prefix for cache.
if
(
filename
.
startswith
(
'<'
)
and
filename
.
endswith
(
'>'
)):
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
)
linecache
.
lazycache
=
lazycache
patch_linecache
()
import
decimal
as
_decimal
...
...
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