tcatch exceptions raised by fiat amount conversion to decimal - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f4a0a900108e600de4a5f2c116f7936e55960a14 DIR parent 0c6d4702964d8b65bfef3b28985df8b2e17f9df5 HTML Author: ThomasV <thomasv@gitorious> Date: Tue, 24 Jun 2014 17:06:04 +0200 catch exceptions raised by fiat amount conversion to decimal Diffstat: M plugins/exchange_rate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- DIR diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py t@@ -642,17 +642,18 @@ class Plugin(BasePlugin): self.btc_e = self.win.amount_e grid = self.btc_e.parent() def fiat_changed(): - fiat_amount = str(self.fiat_e.text()) - if fiat_amount in ["", "."]: + try: + fiat_amount = Decimal(str(self.fiat_e.text())) + except: self.btc_e.setText("") return exchange_rate = self.exchanger.exchange(Decimal("1.0"), self.fiat_unit()) if exchange_rate is not None: - btc_amount = Decimal(fiat_amount) / exchange_rate + btc_amount = fiat_amount/exchange_rate self.btc_e.setAmount(int(btc_amount*Decimal(100000000))) self.fiat_e.textEdited.connect(fiat_changed) def btc_changed(): - btc_amount = self.btc_e.get_amount() + btc_amount = self.btc_e.get_amount() if btc_amount is None: self.fiat_e.setText("") return