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

spurious deprecation warnings #151

Open
anarcat opened this Issue Oct 18, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@anarcat
Copy link

anarcat commented Oct 18, 2018

recently (since after 5.1.3) the feed2exec test suite started failing because this warning was mangling the output of the script:

/home/anarcat/src/feed2exec/.tox/py36/lib/python3.6/site-packages/feedparser.py:345: DeprecationWarning: To avoid breaking existing software while fixing issue 310, a temporary mapping has been created from `updated_parsed` to `published_parsed` if `updated_parsed` doesn't exist. This fallback will be removed in a future version of feedparser.

It's unclear to me how to disable this warning. Any access of the property will trigger the warning. I believe the should be a way to behave properly for the library consumers and disable the warning, for example by having a default value for the get parameter. I have tried that, without any luck:

--- c/feed2exec/email.py
+++ i/feed2exec/email.py
@@ -97,7 +97,7 @@ def make_message(feed, item, to_addr=None, cls=email.message.Message):
     #
     # also, default on the feed updated date
     orig = timestamp = datetime.datetime.utcnow().timestamp()
-    timestamp = item.get('updated_parsed') or orig
+    timestamp = item.get('updated_parsed', item.get('published_parsed', orig))
     if isinstance(timestamp, (datetime.datetime,
                               datetime.date,
                               datetime.time)):

I have reverted to silencing the warnings altogether, which seems suboptimal. It would be better if there was a way to comply with the deprecation warning correctly without having to disable warnings.

Thanks!

@mgedmin

This comment has been minimized.

Copy link

mgedmin commented Nov 3, 2018

@anarcat your code is still accessing updated_parsed even when published_parsed exists. I think you want this instead:

    timestamp = item.get('published_parsed') or orig

or, if you intend to keep feed2exec compatible with older feedparser versions that do not provide published_parsed, you could do

    timestamp = item.get('published_parsed') or item.get('updated_parsed') or orig
@anarcat

This comment has been minimized.

Copy link
Author

anarcat commented Nov 3, 2018

but that would prioritize published_parsed over updated_parsed which is not what i want. it would also still yield warnings if published_parsed is missing or empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.