Using --with-followers or --with-following leads to TypeError

When running mastodon-archive with the switches --with-followers or --with-following, this error is displayed when attempting to save followers or following:

Traceback (most recent call last):
  File "/home/mezzo/.local/bin/mastodon-archive", line 10, in <module>
    sys.exit(main())
  File "/home/mezzo/.local/lib/python3.7/site-packages/mastodon_archive/__init__.py", line 293, in main
    args.command(args)
  File "/home/mezzo/.local/lib/python3.7/site-packages/mastodon_archive/archive.py", line 179, in archive
    data["followers"] = followers
TypeError: 'NoneType' object does not support item assignment

It appears that lines 179 and 192 in archive.py are responsible for this error, as deleting them leads to the disappearance of the error while not impacting the tool's functionality. Please see the respective diff below:

diff --git a/mastodon_archive/archive.py b/mastodon_archive/archive.py
index 9f90d7b..23e3d0b 100644
--- a/mastodon_archive/archive.py
+++ b/mastodon_archive/archive.py
@@ -176,7 +176,6 @@ def archive(args):
         followers = mastodon.account_followers(user.id, limit=100)
         followers = mastodon.fetch_remaining(
             first_page = followers)
-        data["followers"] = followers
 
     if not with_following:
         print("Skipping following")
@@ -189,7 +188,6 @@ def archive(args):
         following = mastodon.account_following(user.id, limit=100)
         following = mastodon.fetch_remaining(
             first_page = following)
-        data["following"] = following
 
     data = {
         'account': user,

Tags: Closed

Comments

Hm, I think you're right. As data is set on line 194, the lines you removed are in fact optional.

– Alex Schroeder 2020-02-12 08:31 UTC


OK, applied it. Thanks!

– Alex Schroeder 2020-02-16 13:35 UTC


This wiki uses a variant of Markdown.

To save this page you must answer this question:

Please write "new issue" into the field below.