Browse Source

remove assert statements that affect branching

- assert statements are still used throughout the MMGen code base for essential
  checks, so use of PYTHONOPTIMIZE will lead to failures.
The MMGen Project 3 years ago
parent
commit
e7d531db07
2 changed files with 15 additions and 20 deletions
  1. 5 6
      mmgen/altcoin.py
  2. 10 14
      mmgen/main_wallet.py

+ 5 - 6
mmgen/altcoin.py

@@ -625,15 +625,14 @@ class CoinInfo(object):
 				return None
 
 		try:
-			assert (
-				cls.external_tests_blacklist[addr_type][tool] == True
-				or coin in cls.external_tests_blacklist[addr_type][tool] )
+			bl = cls.external_tests_blacklist[addr_type][tool]
 		except:
 			pass
 		else:
-			if verbose:
-				msg(f'Tool {tool!r} blacklisted for coin {coin}, addr_type {addr_type!r}')
-			return None
+			if bl == True or coin in bl:
+				if verbose:
+					msg(f'Tool {tool!r} blacklisted for coin {coin}, addr_type {addr_type!r}')
+				return None
 
 		if toolname: # skip whitelists
 			return tool

+ 10 - 14
mmgen/main_wallet.py

@@ -229,21 +229,17 @@ if invoked_as == 'passchg' and ss_in.infile.dirname == g.data_dir:
 	shred_file(
 		ss_in.infile.name,
 		verbose = opt.verbose )
+elif (
+	invoked_as == 'gen'
+	and not opt.outdir
+	and not opt.stdout
+	and not find_file_in_dir( MMGenWallet, g.data_dir )
+	and keypress_confirm(
+		'Make this wallet your default and move it to the data directory?',
+		default_yes = True ) ):
+	ss_out.write_to_file(outdir=g.data_dir)
 else:
-	try:
-		assert invoked_as == 'gen', 'dw'
-		assert not opt.outdir, 'dw'
-		assert not opt.stdout, 'dw'
-		assert not find_file_in_dir( MMGenWallet, g.data_dir ), 'dw'
-		assert keypress_confirm(
-			'Make this wallet your default and move it to the data directory?',
-			default_yes = True ), 'dw'
-	except Exception as e:
-		if str(e) != 'dw':
-			raise
-		ss_out.write_to_file()
-	else:
-		ss_out.write_to_file(outdir=g.data_dir)
+	ss_out.write_to_file()
 
 if invoked_as == 'passchg':
 	if ss_out.ssdata.passwd == ss_in.ssdata.passwd: