Skip to content

Improve error handling and fix counter logic in news function#3141

Open
DepthStrider-x wants to merge 2 commits intogeekcomputers:masterfrom
DepthStrider-x:improve-error-handling-and-counter-logic
Open

Improve error handling and fix counter logic in news function#3141
DepthStrider-x wants to merge 2 commits intogeekcomputers:masterfrom
DepthStrider-x:improve-error-handling-and-counter-logic

Conversation

@DepthStrider-x
Copy link

This PR introduces the following improvements:

  • Added fetch_xml() helper function to handle network errors safely and prevent crashes.
  • Added get_text_or_default() to avoid AttributeError when XML tags are missing.
  • Fixed off-by-one issue in counter logic using enumerate().
  • Removed variable shadowing in loop.
  • Added if __name__ == "__main__" guard to make the script import-safe.

These changes improve reliability and readability without altering the intended functionality of the script.

Removed redundant counter variable and comments in news function.
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