Skip to content
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

UnicodeDecodeError #14

Open
Ygarr opened this issue Mar 29, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@Ygarr
Copy link

commented Mar 29, 2018

xdgmenumaker -n -i -f jwm

Then got:

<?xml version="1.0"?>
<JWM>
/usr/local/bin/xdgmenumaker:321: GtkWarning: Theme directory 256x256@2/animations of theme hicolor has no size field

 icon = icon_theme.lookup_icon(icon, iconsize, gtk.ICON_LOOKUP_FORCE_SVG)
Traceback (most recent call last):
 File "/usr/local/bin/xdgmenumaker", line 874, in <module>
   main(sys.argv[1:])
 File "/usr/local/bin/xdgmenumaker", line 241, in main
   jwm()
 File "/usr/local/bin/xdgmenumaker", line 768, in jwm
   for menu_category in menu():
 File "/usr/local/bin/xdgmenumaker", line 482, in menu
   entry = get_entry_info(desktopfile, ico_paths=ico_paths)
 File "/usr/local/bin/xdgmenumaker", line 419, in get_entry_info
   command = remove_command_keys(command, desktopfile, icon)
 File "/usr/local/bin/xdgmenumaker", line 358, in remove_command_keys
   command = command.replace('"%k"', desktopfile)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd1 in position 70: invalid continuation byte
@gapan

This comment has been minimized.

Copy link
Owner

commented Mar 29, 2018

What is the output of the locale command on your system?

There is probably a .desktop file with an invalid character in its filename somewhere in your system.

@Ygarr

This comment has been minimized.

Copy link
Author

commented Apr 1, 2018

locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

@gapan

This comment has been minimized.

Copy link
Owner

commented May 4, 2018

Can you try applying this patch and see if it outputs anything to stderr?

diff --git a/src/xdgmenumaker b/src/xdgmenumaker
index ba5a037..90fe5f0 100755
--- a/src/xdgmenumaker
+++ b/src/xdgmenumaker
@@ -355,9 +355,13 @@ def remove_command_keys(command, desktopfile, icon):
     # location of the desktop file as either a URI (if for example gotten from
     # the vfolder system) or a local filename or empty if no location is
     # known."
-    command = command.replace('"%k"', desktopfile)
-    command = command.replace("'%k'", desktopfile)
-    command = command.replace('%k', desktopfile)
+    try:
+        command = command.replace('"%k"', desktopfile)
+        command = command.replace("'%k'", desktopfile)
+        command = command.replace('%k', desktopfile)
+    except UnicodeDecodeError:
+        print("ERROR: UnicodeDecodeError while reading {}".format(desktopfile),
+                file=sys.stderr)
     # removing any remaining keys from the command. That can potentially remove
     # any other trailing options after the keys,
     command = command.partition('%')[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.