Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-18-2020, 05:14 PM   #1
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,547
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Inherent "Open With" feature error

A cursory search turned up nothing on this, so apologies if it's already been covered. Please note that this has to do with Calibre's built-in Open With feature and not the third-party plugin of the same name.

The gist is that I can't configure the Open With feature. As soon as I right-click on the ebook format in the Book Details, get the following error:

Code:
calibre, version 5.3.0
ERROR: Unhandled exception: <b>TypeError</b>:string argument without an encoding

calibre 5.3 [64bit]  embedded-python: True is64bit: True
Windows-10-10.0.18362-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.18362')
Python 3.8.5
Windows: ('10', '10.0.18362', 'SP0', 'Multiprocessor Free')
Interface language: None
Traceback (most recent call last):
  File "calibre\gui2\book_details.py", line 668, in contextMenuEvent
  File "calibre\gui2\book_details.py", line 310, in details_context_menu_event
  File "calibre\gui2\book_details.py", line 251, in add_item_specific_entries
  File "calibre\gui2\book_details.py", line 224, in add_format_entries
  File "calibre\gui2\open_with.py", line 349, in populate_menu
  File "calibre\gui2\open_with.py", line 62, in entry_to_icon_text
TypeError: string argument without an encoding
I'm fairly certain that something is hosed with a program I have configured to open epubs, but I can't get TO the Open With configuration to delete the configured entry. Bit of a catch-22.
DiapDealer is offline   Reply With Quote
Old 10-18-2020, 05:18 PM   #2
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,607
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
It's a bug with corrupted icon_data. See this bug (including a fix for it):

https://bugs.launchpad.net/calibre/+bug/1900299

Quote:
This is only a problem because I was tampering with the user data files (trying to rename the open with programs) - but documenting it in case similar issues come up.

Steps to replicate:

1. Add a new program to Calibre's Open With. I used Paint.NET but other programs cause the issue too. Adding an icon to an existing entry doesn't produce this issue.
2. Exit Calibre.
3. Open windows_open_with.json in Notepad++ (my usual text editor, Notepad2, just crashed). Make sure a garbled-looking icon_data entry is in the json. Immediately close the file without modifying or saving it.
4. Open Calibre again.
5. Right-click on the cover in the book info pane/window. It throws this error:

calibre, version 5.3.0
ERROR: Unhandled exception: <b>TypeError</b>:string argument without an encoding

calibre 5.3 [64bit] embedded-python: True is64bit: True
Windows-10-10.0.19041-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19041')
Python 3.8.5
Windows: ('10', '10.0.19041', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: Barnes & Noble (1, 2, 16) && Calibre Power Search Plugin (1, 6, 0) && Clean Comments (0, 1, 0) && Comments Cleaner (1, 2, 1) && Count Pages (1, 10, 0) && Drop Search Results (1, 0, 10) && Embed Comic Metadata (1, 5, 0) && EpubCheck (0, 2, 3) && EpubMerge (2, 11, 0) && Extract ISBN (1, 5, 0) && FanFicFare (3, 24, 1) && Fantastic Fiction (1, 4, 0) && Favourites Menu (1, 0, 5) && Find Duplicates (1, 8, 1) && Generate Cover (1, 5, 25) && Goodreads (1, 5, 1) && Import List (1, 5, 1) && Job Spy (1, 0, 186) && Kindle hi-res covers (0, 5, 0) && Kobo Books (1, 8, 0) && Kobo Utilities (2, 11, 8) && KoboTouchExtended (3, 4, 1) && Library Codes (1, 0, 47) && Manage Series (1, 2, 11) && Modify ePub (1, 6, 1) && MultiColumnSearch (1, 0, 84) && Open With (1, 5, 12) && Quality Check (1, 10, 1) && Reading List (1, 6, 17) && Save To Format (0, 0, 6) && SmartEject (2, 3, 0) && View Manager (1, 5, 7)
Traceback (most recent call last):
**File "calibre\gui2\book_details.py", line 472, in contextMenuEvent
**File "calibre\gui2\book_details.py", line 339, in create_open_cover_with_menu
**File "calibre\gui2\open_with.py", line 349, in populate_menu
**File "calibre\gui2\open_with.py", line 62, in entry_to_icon_text
TypeError: string argument without an encoding

I was able to fix it by exiting Calibre, opening the file again in Notepad++, and carefully removing the corrupted icon_data from the json.

Also, I noticed that adding an icon manually doesn't produce a garbled entry - adding the icon manually only allows image files, so I suspect it may be due to getting the icon from the application binaries.

I've attached a json file with corrupted icon_data in Paint.NET. It also has a well-formed icon_data (for the Calibre 3 viewer) for comparison.
Your post is exactly the "similar issues" I was referring to.

Last edited by ownedbycats; 10-18-2020 at 05:25 PM.
ownedbycats is offline   Reply With Quote
Old 10-18-2020, 05:25 PM   #3
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,607
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
If you're not comfortable trying to fix the windows_open_with.json file yourself (note that doing it wrong can wipe all your open_with settings), attach it and I can remove the garbage data for you.
ownedbycats is offline   Reply With Quote
Old 10-18-2020, 06:07 PM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,547
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Oh, I'm quite comfortable doing that sort of diddling. Thanks for the pointer.

But my main concern is that I didn't do any sort of similar manual tampering to cause corruption of any kind. This is a fairly new/clean install of Calibre 5.3 with no 3rd-party plugins installed. I just configured an external app to open EPUBs through the usual Calibre Open With configuration interface. *shrug* But a fixed bug is a fixed bug, I guess.

Can confirm that a manual cleanup of the windows_open_with.json file got me back in business, though, thanks.
DiapDealer is offline   Reply With Quote
Old 10-18-2020, 06:21 PM   #5
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,607
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by DiapDealer View Post
But my main concern is that I didn't do any sort of similar manual tampering to cause corruption of any kind. This is a fairly new/clean install of Calibre 5.3 with no 3rd-party plugins installed. I just configured an external app to open EPUBs through the usual Calibre Open With configuration interface. *shrug* But a fixed bug is a fixed bug, I guess.
My concern was that if merely opening the file in a text editor was enough to cause the error, any other number of things might cause the same issue. Especially if the same code was used in places more vital than an open with dialog.

Thankfully Kovid was able to fix the issue like 10 minutes after I posted the bug report. It took me longer to write the bug report than it took him to identify and fix it.

I'm not really a programmer, but if I understand the code correctly:
  • the old code attempted to retrieve the icon_data and convert it to text for the json
  • if there was no icon_data, it would replace it with blank.png
  • unfortunately, this resulted in garbage data when it imported the icons from the application binaries
  • the new code seems to check that the icon_data is the right type of data

Last edited by ownedbycats; 10-18-2020 at 08:29 PM.
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Touch "Error Dialog: Cannot open book" tecweston Barnes & Noble NOOK 1 10-21-2011 12:12 AM
Feature Request: configurable space setting for "Insert blank line" in "Look & Feel" therealjoeblow Calibre 15 07-25-2011 03:14 PM
Keep getting "Page Error" on epub file when I open it on my PRS-300 (filesize > 25MB) ryancolm Sigil 6 09-03-2010 10:45 AM
PRS-300 Book won't open "Page Error!" danalynn Sony Reader 9 08-23-2010 05:46 PM
"Unexpected Error" - Won't Open Books Nola_Gal Amazon Kindle 13 12-29-2008 06:07 AM


All times are GMT -4. The time now is 03:34 PM.


MobileRead.com is a privately owned, operated and funded community.