Repository: numba/numba

Issue:
numba -s unknown locale error

- [x] I am using the latest released version of Numba (most recent is visible in
 the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- [x] I have included below a minimal working reproducer (if you are unsure how
 to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).

---

Issue: When I run `numba -s` the system reporting tool aborts because an unknown locale error is raised. 

Suggestion: I think it would be better if `numba -s` printed "unknown" for locale, but does show the rest of my system information.

---

This is on macOS built-in Terminal.app with latest Anaconda base environment and numba 0.43.1 .

```
(base) hfm-1804a:~ deil$ numba -s
System info:
--------------------------------------------------------------------------------
__Time Stamp__
2019-04-16 11:37:30.315661

__Hardware Information__
Machine                                       : x86_64
CPU Name                                      : haswell
CPU count                                     : 8
CPU Features                                  : 
aes avx avx2 bmi bmi2 cmov cx16 f16c fma fsgsbase invpcid lzcnt mmx movbe pclmul
popcnt rdrnd sahf sse sse2 sse3 sse4.1 sse4.2 ssse3 xsave xsaveopt

__OS Information__
Platform                                      : Darwin-18.5.0-x86_64-i386-64bit
Release                                       : 18.5.0
System Name                                   : Darwin
Version                                       : Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64
OS specific info                              : 10.14.4   x86_64

__Python Information__
Python Compiler                               : Clang 4.0.1 (tags/RELEASE_401/final)
Python Implementation                         : CPython
Python Version                                : 3.7.3
Error: The system reporting tool has failed unexpectedly.
Exception was:
unknown locale: UTF-8
If requested, please copy and paste the information between
the dashed (----) lines, or from a given specific section as
appropriate.

=============================================================
IMPORTANT: Please ensure that you are happy with sharing the
contents of the information present, any information that you
wish to keep private you should remove before sharing.
=============================================================
```

Python and other programs work fine. This is what I get from `locale`:
```
(base) hfm-1804a:~ deil$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
```
And probably this is the error from Python that leads to the `numba -s` abort:
```
(base) hfm-1804a:~ deil$ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/deil/software/anaconda3/lib/python3.7/locale.py", line 587, in getlocale
    return _parse_localename(localename)
  File "/Users/deil/software/anaconda3/lib/python3.7/locale.py", line 495, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
```


Discussion:

Resolving patch:
diff --git a/numba/numba_entry.py b/numba/numba_entry.py
--- a/numba/numba_entry.py
+++ b/numba/numba_entry.py
@@ -122,10 +122,14 @@ def scrape_lines(loc):
             ("Python Implementation",
              platform.python_implementation()))
         print(fmt % ("Python Version", platform.python_version()))
-        print(
-            fmt %
-            ("Python Locale ", ' '.join(
-                [x for x in locale.getdefaultlocale() if x is not None])))
+        lcl = []
+        try:
+            for x in locale.getdefaultlocale():
+                if x is not None:
+                    lcl.append(x)
+        except BaseException as e:
+            lcl.append(str(e))
+        print(fmt % ("Python Locale ", ' '.join(lcl)))
 
         print("")
         print("__LLVM information__")


Test patch: