praw-dev / praw

PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.
http://praw.readthedocs.io/
BSD 2-Clause "Simplified" License
3.4k stars 453 forks source link

potential bugs and questions #2017

Closed jiangchao9987 closed 1 month ago

jiangchao9987 commented 3 months ago

Describe the Bug

1)url dismatch 2) replace_more (limit=None) makes the len(comments) bigger than original 3) could you make clear about what is difference between limit = 0 and None in replace_more

Desired Result

1) question 1 when inputing submission = reddit.submission(url = "https://www.reddit.com/r/funny/comments/3g1jfi/buttons/") and expecting the output of print(submission.url)

is the outcome is http://41.media.tumblr.com/a353323397c0aa0b4cfbc21eead3d48f/tumblr_ns7d7t7F6H1rvcmlco1_1280.jpg

2) question 2

the len() of toplevel of reddit.submission.comments are different when replace_more is 0 , None or no replace_more
the len(reddit.submission.comments ) is 198 when replace_more (limit=0) the len(reddit.submission.comments ) is 218 when replace_more (limit=None) the len(reddit.submission.comments ) is 199 when no replace_more

Code to reproduce the bug

import praw

reddit = praw.Reddit(
    "bot1"
)

submission = reddit.submission(url="https://www.reddit.com/r/funny/comments/3g1jfi/buttons/")
print(submission.url)
submission.comments.replace_more(limit=None)
print(len(submission.comments))

submission = reddit.submission(url="https://www.reddit.com/r/funny/comments/3g1jfi/buttons/")
submission.comments.replace_more(limit=0)
print(len(submission.comments))

submission = reddit.submission(url="https://www.reddit.com/r/funny/comments/3g1jfi/buttons/")
print(len(submission.comments))

My code does not include sensitive credentials

Relevant Logs

http://41.media.tumblr.com/a353323397c0aa0b4cfbc21eead3d48f/tumblr_ns7d7t7F6H1rvcmlco1_1280.jpg
218
198
199

This code has previously worked as intended

Yes

Operating System/Environment

Windows

Python Version

3.10.13

PRAW Version

7.7.2.

Links, references, and/or additional comments?

No response

LilSpazJoekp commented 3 months ago
  1. Historically, Reddit is a place to post links. The url attribute refers to the url that is posted to Reddit not the url of the post on Reddit. That would be post.shortlink or post.permalink.
  2. limit=None means there is not a limit to how many MoreComments PRAW will replace. limit=0 means no MoreComments get replaced. This is explained in the docs.
github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity.

Remove the Stale label or comment or this will be closed in 30 days.