Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix upper default critic bug #32

Merged
merged 1 commit into from

3 participants

@GuillaumeCisco

Fix default locale to make a query with upper version.
Leaded to a bug when an unknown locale was passed to this method. Query
was .get('default') instead of .get('DEFAULT').
@limist

Example:

from moneyed.localization import _FORMATTER
_FORMATTER.get_sign_definition('EUR', 'fr_FR')
Traceback (most recent call last):
File "", line 2, in
File "build\bdist.win-amd64\egg\moneyed\localization.py", line 46, in get_sign_definition
if currency_code in local_set:
TypeError: argument of type 'NoneType' is not iterable

@GuillaumeCisco GuillaumeCisco Fix upper default critic bug.
Fix default locale to make a query with upper version.
Leaded to a bug when an unknown locale was passed to this method. Query
was .get('default') instead of .get('DEFAULT').
0cc66b1
@GuillaumeCisco

I'm sorry to ask again @limist
But it seems like a critical bug, and should be fixed as soon as possible.
Please, can you review it.

Thank you very much.

@limist limist merged commit 3ce9e8e into from
@limist
Owner

Thanks for this fix!

@GuillaumeCisco

Thank you very much!

@GuillaumeCisco

Just in case. I think there is the same problem with "get_formatting_definition".
Should be carefully reviewed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2014
  1. @GuillaumeCisco

    Fix upper default critic bug.

    GuillaumeCisco authored
    Fix default locale to make a query with upper version.
    Leaded to a bug when an unknown locale was passed to this method. Query
    was .get('default') instead of .get('DEFAULT').
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/moneyed/localization.py
View
10 src/moneyed/localization.py
@@ -36,12 +36,12 @@ def add_formatting_definition(self, locale, group_size,
'rounding_method': rounding_method}
def get_sign_definition(self, currency_code, locale):
- locale = locale.upper()
currency_code = currency_code.upper()
- if locale in self.sign_definitions:
- local_set = self.sign_definitions.get(locale)
- else:
- local_set = self.sign_definitions.get(DEFAULT)
+
+ if locale.upper() not in self.sign_definitions:
+ locale = DEFAULT
+
+ local_set = self.sign_definitions.get(locale.upper())
if currency_code in local_set:
return local_set.get(currency_code)
Something went wrong with that request. Please try again.