-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LookupError: unknown encoding: None #16
Comments
I tried to debug the issue and it seems, the problem is in init.py in call to self.encoding = unicode(locale.getlocale()[1]) which results in "None". More precisely, the call locale.getlocale() returns None,None. This is caused by call at line 561 localename = _setlocale(category) in locale.py whichresults localename to be 'C'. Any suggestion, what is the expected normal behavior and how to fix it would be greatly appreciated. |
Hi, stumbled upon your comments, here is my few cents. |
Here is a patch which provides a workaround for this issue |
Similar to the crash mentioned by OP relating to loading a pre-saved config file, when attempting to save a config file the following exception occurs:
This appears to be due a locale issue in Python 2.7 (used by metamorphose2) as compared to Python 3.5, with this issue demonstrated by the following Python commands in an interactive Python shell for each of the two Python versions (test system is Linux Mint 18.1 so based on Ubuntu 16.04 LTS):
As demonstrated by the Python 2.7 commands above, the locale related exception can thus be fixed by adding a single line of code to MainWindow/init.py at line 500:
Thus, the code for lines 500 and 501 then reads:
Adding this line fixes all locale related exception errors with metamorphose2 on the mentioned test system, allowing successful saving & loading of config files. Attached is a patch file with this alternate workaround for the issue. |
For all interested in a patched build see #26 |
Simply a workaround to ensure the call to locale.getlocale returns a valid locale. Not sure if this the best solution (not a Python programmer -- yet!) but it works. Have used this patch fine for 2 years now on my own Ubuntu 16.04 based system.
In Ubuntu 16.04 the latest code crashes with error when loading config file pointing to directory containing some files to rename
Traceback (most recent call last):
File "/usr/share/metamorphose2/MainWindow/init.py", line 687, in load_config
configs.load(self)
File "/usr/share/metamorphose2/configs.py", line 66, in load
LoadConfig(main, dlg.GetPath())
File "/usr/share/metamorphose2/configs.py", line 192, in init
self.__load_file(configFilePath)
File "/usr/share/metamorphose2/configs.py", line 365, in __load_file
main.picker.view.reset_dirpicker_on_config_load()
File "/usr/share/metamorphose2/picker/wxPickerView.py", line 560, in reset_dirpicker_on_config_load
self._refresh_items(True)
File "/usr/share/metamorphose2/picker/wxPickerView.py", line 508, in _refresh_items
self.Core.refresh(True)
File "/usr/share/metamorphose2/picker/init.py", line 369, in refresh
self.select_all()
File "/usr/share/metamorphose2/picker/init.py", line 112, in select_all
self.view.select_all(event)
File "/usr/share/metamorphose2/picker/wxPickerView.py", line 625, in select_all
main.show_preview(event)
File "/usr/share/metamorphose2/MainWindow/init.py", line 620, in show_preview
self.on_preview_button(False)
File "/usr/share/metamorphose2/MainWindow/init.py", line 922, in on_preview_button
self.renamer.preview(event)
File "/usr/share/metamorphose2/renamer/init.py", line 72, in preview
self.__preview.generate_names(event)
File "/usr/share/metamorphose2/renamer/preview.py", line 225, in generate_names
self.run(operations)
File "/usr/share/metamorphose2/renamer/preview.py", line 304, in run
newExt, itemToRename)
File "/usr/share/metamorphose2/operations/replace.py", line 91, in rename_item
newName = operations.parse_input(text, original, self)
File "/usr/share/metamorphose2/operations/opButtons.py", line 185, in parse_input
return self.parser.parse_input(text, file, operation)
File "/usr/share/metamorphose2/operations/opParser.py", line 439, in parse_input
value = self.__date_time(0, file, operation)
File "/usr/share/metamorphose2/operations/opParser.py", line 296, in __date_time
return utils.udate(main, dateTime[op + 1], itemDateTime)
File "/usr/share/metamorphose2/utils.py", line 208, in udate
udate = time.strftime(format.encode(main.encoding), itemDateTime)
LookupError: unknown encoding: None
The text was updated successfully, but these errors were encountered: