Skip to content

Fix 3810 import sizes false #3844

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Ayudh-M
Copy link

@Ayudh-M Ayudh-M commented Apr 19, 2025

Pull Request Checklist

  • I’ve read the guidelines for contributing.
  • I created a dedicated branch fix-3810-import-sizes-false.
  • I updated AUTHORS.txt and CHANGES.txt.
  • I ran flake8 nikola tests and pydocstyle — no new warnings.
  • I built the demo site (nikola init -qd demosite && nikola build) and reproduced the WordPress import before/after the fix.

Description — fix #3810

nikola import_wordpress crashed with
TypeError: 'bool' object is not subscriptable
when a WordPress export contained "sizes" => false in _wp_attachment_metadata (WordPress ≥ 6 writes this when an image has no alternate renditions).

This patch:

  • guards against non‑dict metadata[b'sizes']
  • iterates only when a real dict of sizes exists
  • retains existing behaviour for normal exports
  • passes flake8/pydocstyle

No functional change beyond preventing the crash.

Testing

command expected / observed
nikola import_wordpress furious-gamingde.WordPress.2025-01-12.xml --no-downloads --output new_site before patch traceback ending with TypeError: 'bool' object is not subscriptable
same command after patch import completes; site builds; no stack trace
same command with downloads enabled all images imported; single‑size images processed once

Kind request: this fix is part of a university assignment due 19 April.
The change is small (~15 lines) and isolated; any feedback would be greatly appreciated. Thank you!

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.

1 participant