Hi Luca,

Luca Franchini wrote on Sun, Jan 20, 2019 at 03:41:46PM +0100:

> I got an error while running this:
> 
> amidatacyber730:~$ python3.6
> Python 3.6.6 (default, Oct 11 2018, 12:39:19)
> [GCC 4.2.1 Compatible OpenBSD Clang 6.0.0 (tags/RELEASE_600/final)] on o
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import locale
> >>> locale.setlocale(locale.LC_ALL, "it_IT.UTF-8")
> 'it_IT.UTF-8'
> >>> locale.currency(6.4)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python3.6/locale.py", line 262, in currency
>     raise ValueError("Currency formatting is not possible using "
> ValueError: Currency formatting is not possible using the 'C' locale.

The error message that Python is producing is confusing.

Here is what the code in the Python library actually does:

  /usr/local/lib/python3.6/locale.py:
def currency(val, symbol=True, grouping=False, international=False):
    conv = localeconv()
    # check for illegal values
    digits = conv[international and 'int_frac_digits' or 'frac_digits']
    if digits == 127:
        raise ValueError("Currency formatting is not possible using "
                         "the 'C' locale.")

OpenBSD intentionally does not implement any LC_MONETARY or strfmon(3)
functionality because we believe that such functionality does not
belong in the C library but should instead be implemented in
specialized support libraries for user interface design.

Consequently, LC_MONETARY is completely ignored by the OpenBSD base
system and localeconv(3) always returns the values that POSIX
specifies for the C locale, no matter what the user asks for.

You might wish to report upstream (to the Python project) that the
error message is misleading.  It is true that this message can occur
when the user selected LC_MONETARY=C.  But it can also happen when the
operating system does not implement LC_MONETARY support at all.

Yours,
  Ingo

Reply via email to