XZise added a comment.
Okay the problem is a follows: When getting the redirect target the API returns all redirects along the way. And pywikibot is checking if one redirect along that way is redirecting to an item on that list and throws an exception if that happens.
Now I'm not sure how we should fix that. One way would be only throw that exception what the page redirects to itself. That way scripts would at least get some redirects but those then need to detect that they could get into a loop. Currently a script can't get into a loop, because as soon as that could happen it throws that exception.
A more advanced one (which was PS3 of my patch 182530) would be to differ between immediate and ultimate target. Then it would only throw the exception when the immediate/ultimate (depending on what is requested) target couldn't be reached. The default would be to return the immediate target and there would be the same problem as above. But we could add a special state (e.g. by None) which would be the default and return the immediate target but throw an exception when there is a loop somewhere. Now I mention this in the second option as adding an option to the first idea doesn't really make sense (it would be possible though).
Another uncertainty with that option would be what is going to happen when the software allows double redirects. Do we want to add a third option which returns the target which would be chosen by the software? How would we set that option? The chance is probably low as the software is already aware of multiple redirects so there seems to be no complication with following them. Does someone know if they will never support it or if they haven't got to it?
TASK DETAIL https://phabricator.wikimedia.org/T85711
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: XZise Cc: Xqt, Aklapper, XZise, jayvdb, pywikipedia-bugs
pywikipedia-bugs@lists.wikimedia.org