summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__main__.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index a3e0ef1c..ac6b2362 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -21,6 +21,7 @@
 # (ImportError will imply that this module can't be found)
 # convenient exception handling in ranger.py (ImportError)
 
+import locale
 import os
 import sys
 
@@ -152,7 +153,18 @@ def main():
 		print(errormessage)
 		print('ranger requires the python curses module. Aborting.')
 		sys.exit(1)
-	import locale
+
+	try: locale.setlocale(locale.LC_ALL, '')
+	except: print("Warning: Unable to set locale.  Expect encoding problems.")
+
+	if not 'SHELL' in os.environ:
+		os.environ['SHELL'] = 'bash'
+
+	arg = parse_arguments()
+	if arg.clean:
+		sys.dont_write_bytecode = True
+
+	# Need to decide whether to write bytecode or not before importing.
 	import ranger
 	from ranger.ext import curses_interrupt_handler
 	from ranger.core.runner import Runner
@@ -163,17 +175,9 @@ def main():
 	from ranger.shared import (EnvironmentAware, FileManagerAware,
 			SettingsAware)
 
-	try: locale.setlocale(locale.LC_ALL, '')
-	except: print("Warning: Unable to set locale.  Expect encoding problems.")
-
-	if not 'SHELL' in os.environ:
-		os.environ['SHELL'] = 'bash'
-
-	arg = parse_arguments()
-	ranger.arg = arg
-
-	if not ranger.arg.debug:
+	if not arg.debug:
 		curses_interrupt_handler.install_interrupt_handler()
+	ranger.arg = arg
 
 	SettingsAware._setup()