Skip to content

fix: Correct NCX parsing logic - use AND instead of OR#360

Open
1StepMore wants to merge 1 commit into
aerkalov:masterfrom
1StepMore:fix/ncx-navigation-logic
Open

fix: Correct NCX parsing logic - use AND instead of OR#360
1StepMore wants to merge 1 commit into
aerkalov:masterfrom
1StepMore:fix/ncx-navigation-logic

Conversation

@1StepMore

Copy link
Copy Markdown

Problem

When reading EPUBs created by ebooklib itself with ignore_ncx=True, parsing fails with:
AttributeError: 'NoneType' object has no attribute 'get_name'

Root Cause

Line 1728 had incorrect logic using or:

if not self.options.get("ignore_ncx") or not nav_item:
With ignore_ncx=True and nav_item=None, this evaluates to False or True = True, still trying to load NCX.
Fix
Changed or to and:
if toc and not self.options.get("ignore_ncx") and not nav_item:
Now NCX is only loaded when:
- 
toc attribute exists AND
- 
ignore_ncx=False AND  
- 
nav_item=None
Testing
All 9 EPUB tests pass after fix.

@c1924959470

c1924959470 commented May 15, 2026 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants