locale

Issue #1266 closed
Pascal Dreher created an issue

Python crashes when locale settings have been changed and an attempt is made to save a virtual workbook.

import locale
import openpyxl
locale.setlocale(locale.LC_ALL, 'de_DE')
wb = openpyxl.Workbook()
wb.save("qwert.xlsx")

-> Crash

Comments (7)

  1. CharlieC

    I'm pretty certain this is related to your system and your Python install. I certainly can't replicate on my system and wouldn't expect because we never rely on locale settings and always explicitly use UTF8 when interfacing with the file system.

    Can you provide more details about your system?

  2. Pascal Dreher reporter

    Windows 10 with freshly installed Anaconda 4.6.2. Openpyxl 2.6.2... The error occurs both in Jupyter notebooks and directly in the interpreter.

    Based on your hint I made the following change to use the default value of the operating system:

    locale.setlocale(locale.LC_ALL, 'DE_de')
    

    too

    locale.setlocale(locale.LC_ALL, '')
    

    So it works without crashing.

    I also tried it under Linux Mint with Anaconda 4.6.2. and Openpyxl 2.6.2. The first setting is rejected here as unsupported:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <modules>
      File "/home/pascal/anaconda3/lib/python3.7/locale.py", line 604, in setlocale
        return _setlocale(category, locale)
    locale.Error: unsupported locale setting
    
  3. CharlieC

    I can confirm the Windows crash. Because there is no exception, I think this should reported as Python bug to the PSF, preferably providing a stacktrace of Python if possible – this might require a debug build of Python.

    I think the Mint exception is a separate issue, presumably related to what locales are installed.

  4. CharlieC

    As per the related Python bug the problem can be avoided entirely by using the locale "de-DE". The problems is Windows-specific as it is in the Windows Common Runtime. A bug fix for Windows at some point should become available and it's likely that a workaround will be added to Python.

  5. Log in to comment