Change in pysim[master]: pySim-shell: prevent inconsitancy when walking through the FS tree

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Apr 1 15:34:07 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23567 )


Change subject: pySim-shell: prevent inconsitancy when walking through the FS tree
......................................................................

pySim-shell: prevent inconsitancy when walking through the FS tree

When using the method walk() to walk through the filesystem tree, then
the action() callback must not change the currently selected file.
Unfortunately this can easily happen and result in unpredictable
behavior. Lets add a check + an exeception for this to make debugging
easier.

Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c
Related: OS#4963
---
M pySim-shell.py
1 file changed, 7 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/67/23567/1

diff --git a/pySim-shell.py b/pySim-shell.py
index 11953eb..2ac0b26 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -263,7 +263,14 @@
 				self.walk(indent + 1, action, context)
 				fcp_dec = self._cmd.rs.select("..", self._cmd)
 			elif action:
+				df_before_action = self._cmd.rs.selected_file
 				action(f, context)
+				# When walking through the file system tree the action must not
+				# always restore the currently selected file to the file that
+				# was selected before executing the action() callback.
+				if df_before_action != self._cmd.rs.selected_file:
+					raise RuntimeError("inconsistant walk, %s is currently selected but expecting %s to be selected"
+							   % (str(self._cmd.rs.selected_file), str(df_before_action)))
 
 	def do_tree(self, opts):
 		"""Display a filesystem-tree with all selectable files"""

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23567
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c
Gerrit-Change-Number: 23567
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210401/12a10015/attachment.htm>


More information about the gerrit-log mailing list