Skip to content
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

'updated' kludge status #391

Open
dmwyatt opened this issue Aug 25, 2023 · 0 comments
Open

'updated' kludge status #391

dmwyatt opened this issue Aug 25, 2023 · 0 comments

Comments

@dmwyatt
Copy link
Contributor

dmwyatt commented Aug 25, 2023

I just spent a while trying to figure out why this code didn't work as expected:

field = 'updated'
# `data` is a FeedParserDict retrieved from `parsed_feed.feed`...
if field in data and data[field]:
    # do a thing with 'updated'

I found this in the source code:

elif key == "updated":
# Temporarily help developers out by keeping the old
# broken behavior that was reported in issue 310.
# This fix was proposed in issue 328.
if not dict.__contains__(self, "updated") and dict.__contains__(
self, "published"
):
warnings.warn(
"To avoid breaking existing software while "
"fixing issue 310, a temporary mapping has been created "
"from `updated` to `published` if `updated` doesn't "
"exist. This fallback will be removed in a future version "
"of feedparser.",
DeprecationWarning,
stacklevel=_stacklevel,
)
return dict.__getitem__(self, "published")
return dict.__getitem__(self, "updated")

  1. Those issues listed in the comment don't seem to have anything to do with this behavior? Maybe from a previous issue tracker?
  2. How long is this going to be here temporarily? 😀 A brief git blame shows its been in the code for at least 8 years when it was last moved to the utils.py file. I didn't dig any further to see when it was added prior to that.
  3. Since this code was getting run in a pytest test, and the failure included a couple hundred lines of debug information, I missed the warning that the code raises.
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

No branches or pull requests

1 participant