From 684870837777feb9b81ef6213e3eb75c5c73839c Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 27 Jul 2017 07:08:35 +0200 Subject: [PATCH] old style exception, raise --> new style for Python 3 (#10082) * old style raise --> raise() for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style raise --> raise() for Python 3 * old style raise --> raise() for Python 3 * old style exception, raise --> new style for Python 3 --- .../account/chart_of_accounts/import_from_openerp.py | 2 +- erpnext/accounts/doctype/sales_invoice/pos.py | 2 +- erpnext/accounts/utils.py | 4 ++-- erpnext/hr/doctype/process_payroll/process_payroll.py | 2 +- erpnext/hr/doctype/upload_attendance/upload_attendance.py | 2 +- erpnext/patches/v4_0/rename_sitemap_to_route.py | 4 ++-- erpnext/patches/v4_4/make_email_accounts.py | 2 +- .../fix_nonwarehouse_ledger_gl_entries_for_transactions.py | 2 +- .../patches/v8_0/rename_total_margin_to_rate_with_margin.py | 2 +- erpnext/setup/setup_wizard/install_fixtures.py | 4 ++-- erpnext/stock/doctype/item/item.py | 2 +- .../doctype/stock_reconciliation/stock_reconciliation.py | 6 +++--- erpnext/stock/stock_ledger.py | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py index 9893a5b9e0..cb95bd17ae 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/import_from_openerp.py @@ -84,7 +84,7 @@ def get_csv_contents(files_path): try: csv_content.setdefault(file_type, [])\ .append(read_csv_content(csvfile.read())) - except Exception, e: + except Exception as e: continue return csv_content diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index f61931a562..c4458ae9a2 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -469,7 +469,7 @@ def submit_invoice(si_doc, name, doc): si_doc.insert() si_doc.submit() frappe.db.commit() - except Exception, e: + except Exception as e: if frappe.message_log: frappe.message_log.pop() frappe.db.rollback() save_invoice(e, si_doc, name) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 560ba4df93..73fdf6f6f9 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -72,7 +72,7 @@ def get_fiscal_years(transaction_date=None, fiscal_year=None, label="Date", verb error_msg = _("""{0} {1} not in any active Fiscal Year.""").format(label, formatdate(transaction_date)) if verbose==1: frappe.msgprint(error_msg) - raise FiscalYearError, error_msg + raise FiscalYearError(error_msg) def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None): years = [f[0] for f in get_fiscal_years(date, label=_(label), company=company)] @@ -738,4 +738,4 @@ def create_payment_gateway_account(gateway): except frappe.DuplicateEntryError: # already exists, due to a reinstall? - pass \ No newline at end of file + pass diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py index b58c7872cc..287ce61b62 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.py +++ b/erpnext/hr/doctype/process_payroll/process_payroll.py @@ -311,7 +311,7 @@ class ProcessPayroll(Document): journal_entry.submit() jv_name = journal_entry.name self.update_salary_slip_status(jv_name = jv_name) - except Exception, e: + except Exception as e: frappe.msgprint(e) return jv_name diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py index fc1a8ae333..78d5aee81d 100644 --- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py @@ -121,7 +121,7 @@ def upload(): try: check_record(d) ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True)) - except Exception, e: + except Exception as e: error = True ret.append('Error for row (#%d) %s : %s' % (row_idx, len(row)>1 and row[1] or "", cstr(e))) diff --git a/erpnext/patches/v4_0/rename_sitemap_to_route.py b/erpnext/patches/v4_0/rename_sitemap_to_route.py index 257580bac6..ffb1fda144 100644 --- a/erpnext/patches/v4_0/rename_sitemap_to_route.py +++ b/erpnext/patches/v4_0/rename_sitemap_to_route.py @@ -12,6 +12,6 @@ def execute(): frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route") frappe.model.rename_field("Sales Partner", "parent_website_sitemap", "parent_website_route") - except Exception, e: + except Exception as e: if e.args[0]!=1054: - raise \ No newline at end of file + raise diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py index 126acfcd1e..510fe3ae6d 100644 --- a/erpnext/patches/v4_4/make_email_accounts.py +++ b/erpnext/patches/v4_4/make_email_accounts.py @@ -78,7 +78,7 @@ def execute(): def insert_or_update(account): try: account.insert() - except frappe.NameError, e: + except frappe.NameError as e: if e.args[0]=="Email Account": existing_account = frappe.get_doc("Email Account", e.args[1]) for key, value in account.as_dict().items(): diff --git a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py index 2b92b17f11..58da0594ea 100644 --- a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py +++ b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py @@ -34,7 +34,7 @@ def execute(): voucher = frappe.get_doc(voucher_type, voucher_no) voucher.make_gl_entries() frappe.db.commit() - except Exception, e: + except Exception as e: print frappe.get_traceback() rejected.append([voucher_type, voucher_no]) frappe.db.rollback() diff --git a/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py b/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py index 3fc477ec8f..4065438796 100644 --- a/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py +++ b/erpnext/patches/v8_0/rename_total_margin_to_rate_with_margin.py @@ -19,6 +19,6 @@ def execute(): def rename_field_if_exists(doctype, old_fieldname, new_fieldname): try: rename_field(doctype, old_fieldname, new_fieldname) - except Exception, e: + except Exception as e: if e.args[0] != 1054: raise diff --git a/erpnext/setup/setup_wizard/install_fixtures.py b/erpnext/setup/setup_wizard/install_fixtures.py index f139d92f35..ea6da04641 100644 --- a/erpnext/setup/setup_wizard/install_fixtures.py +++ b/erpnext/setup/setup_wizard/install_fixtures.py @@ -233,10 +233,10 @@ def install(country=None): try: doc.insert(ignore_permissions=True) - except frappe.DuplicateEntryError, e: + except frappe.DuplicateEntryError as e: # pass DuplicateEntryError and continue if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name: # make sure DuplicateEntryError is for the exact same doc and not a related doc pass else: - raise \ No newline at end of file + raise diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 2c6aab52c1..14e1dcce09 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -696,7 +696,7 @@ def _msgprint(msg, verbose): if verbose: msgprint(msg, raise_exception=True) else: - raise frappe.ValidationError, msg + raise frappe.ValidationError(msg) def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0): diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 9c425295c5..360ebca11e 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -143,16 +143,16 @@ class StockReconciliation(StockController): # item should not be serialized if item.has_serial_no == 1: - raise frappe.ValidationError, _("Serialized Item {0} cannot be updated using Stock Reconciliation, please use Stock Entry").format(item_code) + raise frappe.ValidationError(_("Serialized Item {0} cannot be updated using Stock Reconciliation, please use Stock Entry").format(item_code)) # item managed batch-wise not allowed if item.has_batch_no == 1: - raise frappe.ValidationError, _("Batched Item {0} cannot be updated using Stock Reconciliation, instead use Stock Entry").format(item_code) + raise frappe.ValidationError(_("Batched Item {0} cannot be updated using Stock Reconciliation, instead use Stock Entry").format(item_code)) # docstatus should be < 2 validate_cancelled_item(item_code, item.docstatus, verbose=0) - except Exception, e: + except Exception as e: self.validation_messages.append(_("Row # ") + ("%d: " % (row_num)) + cstr(e)) def update_stock_ledger(self): diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 80226914f9..7c6b34bd90 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -378,7 +378,7 @@ class update_entries_after(object): if self.verbose: frappe.throw(msg, NegativeStockError, title='Insufficent Stock') else: - raise NegativeStockError, msg + raise NegativeStockError(msg) def get_previous_sle(args, for_update=False): """