about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-08-07 03:15:53 +0200
committerhut <hut@lavabit.com>2012-08-07 03:18:23 +0200
commit6c0ccee49a0113339a2603696755a880116efe97 (patch)
tree7d3ba4b4bd836915812376e88ab03615da568082 /ranger
parent49665d249cd6ccb83bfd1ff11160d58c025d8cb7 (diff)
downloadranger-6c0ccee49a0113339a2603696755a880116efe97.tar.gz
core.tab: fix weakref bug with python2 that breaks fm.thisfile
in python2, weak references are not equal to the original object when
tested with "==", and this breaks Tab._set_thisfile_from_signal and
Tab._on_tab_change in python2 if weak=True is used in signal bindings
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/tab.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/ranger/core/tab.py b/ranger/core/tab.py
index 153611df..2fd71cb6 100644
--- a/ranger/core/tab.py
+++ b/ranger/core/tab.py
@@ -2,6 +2,7 @@
 # This software is distributed under the terms of the GNU GPL version 3.
 
 import os
+import sys
 from os.path import abspath, normpath, join, expanduser, isdir
 
 from ranger.container.history import History
@@ -17,9 +18,13 @@ class Tab(FileManagerAware, SettingsAware):
 		self.pointer = 0
 		self.path = abspath(expanduser(path))
 		self.pathway = ()
+		# NOTE: in the line below, weak=True works only in python3.  In python2,
+		# weak references are not equal to the original object when tested with
+		# "==", and this breaks _set_thisfile_from_signal and _on_tab_change.
 		self.fm.signal_bind('move', self._set_thisfile_from_signal, priority=0.1,
-				weak=True)
-		self.fm.signal_bind('tab.change', self._on_tab_change, weak=True)
+				weak=(sys.version > '3'))
+		self.fm.signal_bind('tab.change', self._on_tab_change,
+				weak=(sys.version > '3'))
 
 	def _set_thisfile_from_signal(self, signal):
 		if self == signal.tab: