Skip to content

urllib.retrieve's reporthook called with non-helpful value #43374

Closed as not planned

Description

@sidnei
mannequin
BPO 1490929
Nosy @orsenthil, @devdanzin, @4kir4, @iritkatriel
Files
  • progresshook.diff: Patch adding progresshook
  • test_urllib.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/orsenthil'
    closed_at = None
    created_at = <Date 2006-05-18.13:22:13.000>
    labels = ['easy', '3.8', '3.9', '3.10', 'type-feature', 'library']
    title = "urllib.retrieve's reporthook called with non-helpful value"
    updated_at = <Date 2020-10-26.08:00:19.394>
    user = 'https://bugs.python.org/sidnei'

    bugs.python.org fields:

    activity = <Date 2020-10-26.08:00:19.394>
    actor = 'iritkatriel'
    assignee = 'orsenthil'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2006-05-18.13:22:13.000>
    creator = 'sidnei'
    dependencies = []
    files = ['12271', '21766']
    hgrepos = []
    issue_num = 1490929
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['60914', '77257', '81786', '134357', '174870', '379618', '379649']
    nosy_count = 7.0
    nosy_names = ['orsenthil', 'sidnei', 'ajaksu2', 'zanella', 'nelchael', 'akira', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1490929'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Linked PRs

    Activity

    1. sidnei commented on May 18, 2006

      sidneimannequin
      MannequinAuthor

      Seems like the 'reporthook', when provided to the
      'retrieve' function of urllib will be called with
      (blocknumber, blocksize, totalsize).

      However, the call to read() might return *less* than
      'blocksize' bytes (I believe), so it should imho be
      called with len(block) as the second argument instead.
      Or maybe add a fourth argument 'readbytes'.

    2. added
      stdlib
      type-feature
      on May 18, 2006
    3. nelchael commented on Dec 7, 2008

      nelchaelmannequin
      Mannequin

      Attached patch adds new argument: progresshook - it will be passed two
      arguments: count of downloaded bytes and total file size (or -1 if it's
      not available).

      Introducing new argument instead of modifying reporthook maintains
      backwards compatibility, also allows removal of reporthook at one point
      in the future.

      This patch is against r30 SVN tag.

    4. devdanzin commented on Feb 12, 2009

      devdanzinmannequin
      Mannequin

      Patch has docs, tests needed.

    5. zanella commented on Apr 24, 2011

      zanellamannequin
      Mannequin

      Simple (lazy) test case added.

      It just replicates one test case of reporthook to work with progresshook.

      The testcases assume the hard-coded value of blocksize on urllib, maybe it should become a public property.

      Also commented on diff: http://bugs.python.org/review/1490929/show

    6. 4kir4 commented on Nov 5, 2012

      4kir4mannequin
      Mannequin

      Related bpo-16409

    7. iritkatriel commented on Oct 25, 2020

      @iritkatriel
      Member

      The code in urllib is different now but I see that a test very similar to the one in the patch exists, so was this fixed?

      def test_reporthook_8193_bytes(self):

    8. orsenthil commented on Oct 26, 2020

      @orsenthil
      Member

      so was this fixed?

      Irit, not really. This is adding another hook called "progress hook" in addition to the "report hook". We need to evaluate if this is really required.

    9. 15 remaining items

    10. removed
      3.9 (EOL)
      3.8 (EOL)
      3.13
      3.14
      3.15
      on Jan 9, 2026
    11. added a commit that references this issue on Jan 11, 2026
    12. orsenthil commented on Jan 12, 2026

      @orsenthil
      Member

      We will close this as wont do. There is no right answer for the "fix" here; we are dealing with the original API design, and changing the behavior of reporthook's argument is not bring any significant benefit.

      The existing behavior as established in https://hg.python.org/cpython/rev/8c48eb0239ca seems good to me, and we can close this issue as wont do.

    13. added a commit that references this issue on Jan 12, 2026
    14. orsenthil commented on Jan 12, 2026

      @orsenthil
      Member

      Let's close this one. Open issue resulted in some confusion regarding a 'fix'

      #142653 (comment)

      I don't think any confusion is worth for this issue at the moment.

    15. hugovk commented on Jan 12, 2026

      @hugovk
      Member

      (Re-closing as "not planned")

    16. added a commit that references this issue on Jan 12, 2026
    17. added 2 commits that reference this issue on Feb 15, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions