This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch python-editing-embedding
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/python-editing-embedding by
this push:
new 8e23be7474 Use pop() instead of del to delete keys from the
self.modules dictionary for Python scripts, so KeyError isn't thrown when the
key is missing.
8e23be7474 is described below
commit 8e23be7474c5f392173c566ea4afce92a56bdfaa
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Thu Apr 30 05:02:56 2026 +0200
Use pop() instead of del to delete keys from the self.modules
dictionary for Python scripts, so KeyError isn't thrown when the
key is missing.
Remove the saving to temporary files, it's not used for any
other scripting language, and can cause bugs when the temporary
files already exist from previous errors.
Patch by: me
---
main/scripting/source/pyprov/pythonscript.py | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/main/scripting/source/pyprov/pythonscript.py
b/main/scripting/source/pyprov/pythonscript.py
index 9f4fb56e86..677ff90006 100644
--- a/main/scripting/source/pyprov/pythonscript.py
+++ b/main/scripting/source/pyprov/pythonscript.py
@@ -508,7 +508,7 @@ class ProviderContext:
# with all zeroes, and even if it worked, the smallest granularity for ZIP
file
# timestamps is 2 seconds, which isn't good enough.
def removeModuleByUrl( self, url ):
- del self.modules[ url ]
+ self.modules.pop( url, None )
def createEditorDialog( ctx ):
smgr = ctx.ServiceManager
@@ -675,12 +675,9 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode,
XPropertySet, XInvocation,
elif event.ActionCommand == "Save":
toWrite = uno.ByteSequence(
self.editor.getControl("EditorTextField").getText().encode("utf-8"))
- copyUrl = self.uri() + ".orig"
- self.provCtx.sfa.move( self.uri(), copyUrl )
log.debug( "Saving Python macro to URI " + self.uri() )
self.provCtx.sfa.writeFile( self.uri(), BytesInputStream(
toWrite.value ) )
self.provCtx.removeModuleByUrl( self.uri() )
- self.provCtx.sfa.kill( copyUrl )
except Exception as e:
# TODO: add an error box here !
log.error( lastException2String() )
@@ -839,12 +836,9 @@ class FileBrowseNode( unohelper.Base, XBrowseNode,
XPropertySet, XInvocation, XA
elif event.ActionCommand == "Save":
toWrite = uno.ByteSequence(
self.editor.getControl("EditorTextField").getText().encode("utf-8"))
- copyUrl = self.uri() + ".orig"
- self.provCtx.sfa.move( self.uri(), copyUrl )
log.debug( "Saving Python macro to URI " + self.uri() )
self.provCtx.sfa.writeFile( self.uri(), BytesInputStream(
toWrite.value ) )
self.provCtx.removeModuleByUrl( self.uri() )
- self.provCtx.sfa.kill( copyUrl )
except Exception as e:
# TODO: add an error box here !
log.error( lastException2String() )