UnicodeDecodeError when pressing "Show All" or "New Note"

Bug #1444805 reported by Gonzalo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
indicator-stickynotes
Fix Released
Medium
Umang Varma

Bug Description

Hi.
When I press the "Show All" button at the top of Ubuntu 14.04 Unity, I get this error:

Traceback (most recent call last):
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 134, in showall
    self.nset.showall(*args)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 143, in showall
    note.show(*args)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 70, in show
    self.gui = self.gui_class(note=self)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/gui.py", line 60, in __init__
    self.css_template = Template(css_file.read())
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 17: ordinal not in range(128)

When I press "New Note" I get this one instead:

Traceback (most recent call last):
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 131, in new_note
    self.nset.new()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 138, in new
    note.show()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 70, in show
    self.gui = self.gui_class(note=self)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/gui.py", line 60, in __init__
    self.css_template = Template(css_file.read())
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 17: ordinal not in range(128)

I tried creating a backup of /home/<user>/.config/indicator-stickynotes and deleting that file, but when I run stickynotes again (with the command "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py") I get this:

Traceback (most recent call last):
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 127, in open
    encoding='utf-8') as fsock:
FileNotFoundError: [Errno 2] No such file or directory: '/home/gonzalo/.config/indicator-stickynotes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 196, in <module>
    main()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 189, in main
    indicator = IndicatorStickyNotes(args)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 53, in __init__
    self.nset.open()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 131, in open
    self.new()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 138, in new
    note.show()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 70, in show
    self.gui = self.gui_class(note=self)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/gui.py", line 60, in __init__
    self.css_template = Template(css_file.read())
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 17: ordinal not in range(128)

If I create a new empty "indicator-stickynotes" file, it starts, but when I try "New Note" (only thing I can do since the configuration, thus the notes, is empty) it throws the same exact error from above.

It has happened since I've run one of the Ubuntu 14.04 packages updates a while ago, but I can't remember when (1 or 2 weeks ago I believe)

Revision history for this message
Gonzalo (gonzaw308) wrote :

Further info. I read that maybe this is a problem with the default locale encoding used in Ubuntu and in Python 3 (when reading a file)
Here is my ~/.pam_environment file just in case then:

LANGUAGE=en
LANG=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_MONETARY=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
PAPERSIZE=letter

Revision history for this message
Andy Rozman (andy-rozman) wrote :

I have similar problem, which is reason why I am adding it here. I have Ubuntu 14.04, I am suing sticky notes for two years now, but it stopped working few days ago... It happens on startup:

/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py
Traceback (most recent call last):
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 196, in <module>
    main()
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 189, in main
    indicator = IndicatorStickyNotes(args)
  File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 53, in __init__
    self.nset.open()
  File "/home/andy/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 128, in open
    self.loads(fsock.read())
  File "/usr/lib/python3.4/codecs.py", line 313, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 0: invalid continuation byte

Please help... I have some data on my notes which I need back...

Revision history for this message
Gonzalo (gonzaw308) wrote :

If you just want data back, you can get it in this file:
/home/<user>/.config/indicator-stickynotes

The notes themselves are wrapped in tags, but you can get your notes back if you parse it correctly. What doesn't work is the app itself.

Revision history for this message
Umang Varma (umang) wrote :

I do not have enough information to fix this bug and am marking it incomplete. If you do not have any personal information in the data file, please send it to me via email and I will try to debug this error.

Changed in indicator-stickynotes:
status: New → Incomplete
Revision history for this message
Gonzalo (gonzaw308) wrote :

I deleted the personal information from it (before backing it up) and it still gives me the same error, so I'll attach the updated data file

Revision history for this message
Gonzalo (gonzaw308) wrote :
Revision history for this message
Umang Varma (umang) wrote :

That's odd. That file works for me. Could you post the exact error and when you get it (I assume this happens when you hit Show All, not on startup, which is the issue Andy Rozman is facing.

Revision history for this message
Gonzalo (gonzaw308) wrote :

Yes, like I mentioned, the error happens when I hit "Show All" or "New Note", not on startup. The stacktrace is the one I posted in the OP.
It seems the issue has something to do with Python 3.4 and decoding utf8 or something like that.

Do you need any other info about my settings (packages installed, ubuntu configurations, etc)?

Revision history for this message
Umang Varma (umang) wrote :

Hi,

Could you edit gui.py (in the latest version, this is located in /usr/share/indicator-stickynotes/stickynotes/gui.py) and change line number 49, which currently says

        with open(os.path.join(self.path, "style.css")) as css_file:

to the following:

        with open(os.path.join(self.path, "style.css"), encoding="utf-8") as css_file:

Please let me know if this fixes your problem. If it does, I will incorporate it into the next version.

Revision history for this message
Umang Varma (umang) wrote :

Launched wrapped the text, so just to clarify: "with open [....] as css_file" should all be one line. Do not change the indentation (the number of spaces on the left of the text)

Revision history for this message
Gonzalo (gonzaw308) wrote :

Yes! That does it!

I can open it perfectly now with that change. Thanks

Revision history for this message
Umang Varma (umang) wrote :

Fantastic! This will be fixed in the new version, which I will upload this week.

Thanks for your bug report.

Changed in indicator-stickynotes:
assignee: nobody → Umang Varma (umang)
status: Incomplete → Fix Committed
Umang Varma (umang)
Changed in indicator-stickynotes:
status: Fix Committed → Fix Released
milestone: none → 0.5.0
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.