wolph / python-progressbar

Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
http://progressbar-2.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
859 stars 103 forks source link

ValueError: Value 40 is out of range, should be between 0 and 39 #268

Closed Mennaruuk closed 2 years ago

Mennaruuk commented 2 years ago

Hello WoLpH, I hope you are doing well.

Thank you for your amazing project, it's very helpful.

Description

I get the following error:

Traceback (most recent call last):
  File "C:\Users\Menna\Desktop\funny\memes\delete.py", line 66, in <module>
    for url in pbar(data):
  File "C:\Users\Menna\AppData\Local\Programs\Python\Python310\lib\site-packages\progressbar\bar.py", line 550, in __next__
    self.update(self.value + 1)
  File "C:\Users\Menna\AppData\Local\Programs\Python\Python310\lib\site-packages\progressbar\bar.py", line 661, in update
    raise ValueError(
ValueError: Value 40 is out of range, should be between 0 and 39

Code

  1. Save the code below as main.py https://pastebin.com/xrm7kZkU

  2. Install waybackpack (GitHub repo) pip install waybackpack

  3. Run the following command: main.py -u tiredarabwoman -from 20220126

  4. After a minute, you'll get this prompt: 2 deleted Tweets have been found. Would you like to download them all? Type yes or no. Type yes and press Enter. You should get the error above.

Versions

Thank you again.

wolph commented 2 years ago

I'm really sorry for the slow response... I didn't see this issue. It seems the pastebin has been removed in the mean time, but I can think of 2 scenarios where this can happen:

  1. An off-by-1 error. A range(40) returns 0 to 39 which does not include 40.
  2. The maximum value grows during iteration. In that case you can disable the error using the max_error=False parameter to the progressbar :)