AttributeError: 'NoneType' object has no attribute 'get'

Bug #1796497 reported by Simon Schütte
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Conversion Error

Error Log:

1/
Convert book 1 of 1 (American Like Me)
Conversion options changed from defaults:
read_metadata_from_opf: u'C:\\Users\\LOCHL_~1\\AppData\\Local\\Temp\\calibre_pg8hiw\\4biq5m.opf'
cover: u'C:\\Users\\LOCHL_~1\\AppData\\Local\\Temp\\calibre_pg8hiw\\zumafq.jpeg'
mobi_file_type: u'new'
output_profile: 'kindle_fire'
verbose: 2
Resolved conversion options
calibre version: 3.32.0
{'asciiize': False,
'author_sort': None,
'authors': None,
'base_font_size': 0.0,
'book_producer': None,
'change_justification': u'original',
'chapter': u"//*[((name()='h1' or name()='h2') and re:test(., '\\s*((chapter|book|section|part)\\s+)|((prolog|prologue|epilogue)(\\s+|$))', 'i')) or @class = 'chapter']",
'chapter_mark': u'pagebreak',
'comments': None,
'cover': u'C:\\Users\\LOCHL_~1\\AppData\\Local\\Temp\\calibre_pg8hiw\\zumafq.jpeg',
'debug_pipeline': None,
'dehyphenate': True,
'delete_blank_paragraphs': True,
'disable_font_rescaling': False,
'dont_compress': False,
'duplicate_links_in_toc': False,
'embed_all_fonts': False,
'embed_font_family': None,
'enable_heuristics': False,
'expand_css': False,
'extra_css': None,
'extract_to': None,
'filter_css': u'',
'fix_indents': True,
'font_size_mapping': None,
'format_scene_breaks': True,
'html_unwrap_factor': 0.4,
'input_encoding': None,
'input_profile': <calibre.customize.profiles.InputProfile object at 0x0000019BBACA0898>,
'insert_blank_line': False,
'insert_blank_line_size': 0.5,
'insert_metadata': False,
'isbn': None,
'italicize_common_cases': True,
'keep_ligatures': False,
'language': None,
'level1_toc': None,
'level2_toc': None,
'level3_toc': None,
'line_height': 0.0,
'linearize_tables': False,
'margin_bottom': 5.0,
'margin_left': 5.0,
'margin_right': 5.0,
'margin_top': 5.0,
'markup_chapter_headings': True,
'max_toc_links': 50,
'minimum_line_height': 120.0,
'mobi_file_type': u'new',
'mobi_ignore_margins': False,
'mobi_keep_original_images': False,
'mobi_toc_at_start': False,
'no_chapters_in_toc': False,
'no_inline_navbars': True,
'no_inline_toc': False,
'output_profile': <calibre.customize.profiles.KindleFireOutput object at 0x0000019BBACA0EF0>,
'page_breaks_before': u'/',
'personal_doc': u'[PDOC]',
'prefer_author_sort': False,
'prefer_metadata_cover': False,
'pretty_print': False,
'pubdate': None,
'publisher': None,
'rating': None,
'read_metadata_from_opf': u'C:\\Users\\LOCHL_~1\\AppData\\Local\\Temp\\calibre_pg8hiw\\4biq5m.opf',
'remove_fake_margins': True,
'remove_first_image': False,
'remove_paragraph_spacing': False,
'remove_paragraph_spacing_indent_size': 1.5,
'renumber_headings': True,
'replace_scene_breaks': u'',
'search_replace': '[]',
'series': None,
'series_index': None,
'share_not_sync': False,
'smarten_punctuation': False,
'sr1_replace': None,
'sr1_search': None,
'sr2_replace': None,
'sr2_search': None,
'sr3_replace': None,
'sr3_search': None,
'start_reading_at': None,
'subset_embedded_fonts': False,
'tags': None,
'timestamp': None,
'title': None,
'title_sort': None,
'toc_filter': None,
'toc_threshold': 6,
'toc_title': None,
'transform_css_rules': '[]',
'unsmarten_punctuation': False,
'unwrap_lines': True,
'use_auto_toc': False,
'verbose': 2}
InputFormatPlugin: EPUB Input running
on C:\Users\LOCHL_~1\AppData\Local\Temp\calibre_pg8hiw\smwlzw.epub
Failed to parse as XML, parsing as tag soup
Traceback (most recent call last):
File "site-packages\calibre\ebooks\oeb\polish\parsing.py", line 94, in parse
ValueError: Root tag is not <html> in the XHTML namespace

Parsing all content...
Parsing ch26a.xhtml ...
Parsing ch28.xhtml ...
Parsing ch27a.xhtml ...
Parsing ch12a.xhtml ...
Parsing ch25.xhtml ...
Parsing title.xhtml ...
Parsing ch32.xhtml ...
Parsing ch29.xhtml ...
Parsing ch32a.xhtml ...
Parsing ch06.xhtml ...
Parsing ch31a.xhtml ...
Parsing conclusion.xhtml ...
Parsing conclusion01.xhtml ...
Parsing copy.xhtml ...
Parsing ch26.xhtml ...
Parsing ch11.xhtml ...
Parsing ch24.xhtml ...
Parsing cover.xhtml ...
Parsing ch24a.xhtml ...
Parsing ded.xhtml ...
Parsing ch27.xhtml ...
Parsing ch28a.xhtml ...
Parsing ch02.xhtml ...
Parsing ch18.xhtml ...
Parsing styles/SS_global.css ...
Parsing ch23a.xhtml ...
Parsing ch02a.xhtml ...
Parsing ch13a.xhtml ...
Parsing ch05.xhtml ...
Parsing ch14a.xhtml ...
Parsing ch03.xhtml ...
Parsing ch01.xhtml ...
Parsing ch01a.xhtml ...
Parsing ch13.xhtml ...
Parsing ch15a.xhtml ...
Parsing ch06a.xhtml ...
Parsing ch16.xhtml ...
Parsing ch04a.xhtml ...
Parsing ch05a.xhtml ...
Parsing ch03a.xhtml ...
Parsing ch09a.xhtml ...
Parsing ch17a.xhtml ...
Parsing styles/9781501180934.css ...
Parsing toc.xhtml ...
Parsing ch08a.xhtml ...
Parsing ch14.xhtml ...
Parsing ch18a.xhtml ...
Parsing ch19.xhtml ...
Parsing ch19a.xhtml ...
Parsing ch11a.xhtml ...
Parsing ch20.xhtml ...
Parsing ch20a.xhtml ...
Parsing ch21.xhtml ...
Parsing ch08.xhtml ...
Parsing ch21a.xhtml ...
Parsing ch22.xhtml ...
Parsing ch22a.xhtml ...
Parsing ch04.xhtml ...
Parsing ch23.xhtml ...
Parsing ch07.xhtml ...
Parsing SS_US_adult_signup_back.xhtml ...
Parsing author.xhtml ...
Parsing ch25a.xhtml ...
Parsing acknowledgments.xhtml ...
Parsing SS_US_adult_signup_front.xhtml ...
Parsing ch10a.xhtml ...
Parsing ch31.xhtml ...
Parsing ch30a.xhtml ...
Parsing ch30.xhtml ...
Parsing ch15.xhtml ...
Parsing styles/SS_signup.css ...
Parsing ch07a.xhtml ...
Parsing ch09.xhtml ...
Parsing ch16a.xhtml ...
Parsing ch10.xhtml ...
Parsing ch17.xhtml ...
Parsing intro.xhtml ...
Parsing introa.xhtml ...
Parsing ch29a.xhtml ...
Parsing ch12.xhtml ...
Reading TOC from HTML...
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Found image encoded as data URI converting it to normal image
Merging user specified metadata...
Detecting structure...
Flattening CSS and remapping font sizes...
Python function terminated unexpectedly
'NoneType' object has no attribute 'get' (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 101, in main
File "site.py", line 78, in run_entry_point
File "site-packages\calibre\utils\ipc\worker.py", line 199, in main
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 42, in gui_convert_override
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 27, in gui_convert
File "site-packages\calibre\ebooks\conversion\plumber.py", line 1227, in run
File "site-packages\calibre\ebooks\oeb\transforms\flatcss.py", line 215, in __call__
File "site-packages\calibre\ebooks\oeb\transforms\flatcss.py", line 297, in stylize_spine
AttributeError: 'NoneType' object has no attribute 'get'

I think this might be a combination of a formatting error in the eBook file (missing root element) and a small bug (maybe a formatting error? in the python code).

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1796497

Attach the ebook file demonstrating/reproducing the problem to this bug report. You can do that by clicking the "Add attachment or patch" link at the bottom of the bug's page. If the file you are attaching is copyrighted, mark the bug as private. You can do this by clicking the tiny yellow icon next to "This report contains Public information" in the top right area of the bug's page.

 status incomplete

Changed in calibre:
status: New → Incomplete
Revision history for this message
Hot Giraffe (hotgiraffe) wrote :

This bug also affects me on several EPUB books.
Attaching a sample book that throws 'NoneType' object has no attribute 'get' exception

information type: Public → Private
Revision history for this message
Kovid Goyal (kovid) wrote :

That EPUB file is invalid, it incorrectly places the NCX file into the
spine. I will add a workaround for it in the next calibre release, but
you can fix it yourself by opening in the calibre editor, editing the of
file and removing item_51 entry from the <spine>

 status invalid

Changed in calibre:
status: Incomplete → Invalid
Revision history for this message
Kovid Goyal (kovid) wrote :

Actually there is no good way to workaround this, you will need to fix
them by hand before converting.

Revision history for this message
Hot Giraffe (hotgiraffe) wrote :

Oh, thanks, I will notify the book producers that they need to change their tooling!
A workaround would be nice though ))

Kovid Goyal (kovid)
information type: Private → Public
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: Invalid → Fix Released
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.