regosen/gallery_get

Strange 'int' errors on Python 3.6.5 / Ubuntu 18.04

Closed this issue · 1 comments

dgw commented

I kept banging up against this strange issue while trying to write a PBase plugin. The issue went away when I started testing in Python 2.7, but… this still shouldn't happen.

$ python3 --version
Python 3.6.5
$ python3 ./gallery_get.py 'https://secure2.pbase.com/<user>/<album_name>?page=all' ~/Downloads/pbase
Using pbase plugin...

------------------------------------------------------------
Traceback (most recent call last):
  File "./gallery_get.py", line 323, in run
    self.run_internal()
  File "./gallery_get.py", line 309, in run_internal
    self.process_redirect_page(info, response)
  File "./gallery_get.py", line 285, in process_redirect_page
    (info.path,info.subtitle) = safe_unpack(jpegs[0],info.subtitle)
  File "./gallery_get.py", line 67, in safe_unpack
    return (obj[0],safe_str(obj[1]))
  File "./gallery_get.py", line 58, in safe_str
    name = name.replace(":",";") # to preserve emoticons
AttributeError: 'int' object has no attribute 'replace'

Numerous attempts to figure out where this supposed 'int' object comes from using pdb went nowhere. At first, because pdb was using py2, so I couldn't even reproduce. Then when I started using pdb3 specifically, the error would pop up consistently in a place that made no sense to me.

My plugin's redirect method was mocked to return a set with one known-good image page, and I put a breakpoint just before the return and stepped out of that through a single iteration of this loop:

gallery_get/gallery_get.py

Lines 380 to 384 in a90e21a

for idx, link in enumerate(links):
(link,subtitle) = safe_unpack(link, subtitle)
link = safe_url(self.url, link)
safe_makedirs(root)
add_job(plugin=plugin, redirect=link, dest=root, subtitle=subtitle, index=idx+1)

Upon completing the first loop iteration and stepping into the for line, that's when the exception would fire, inconveniently terminating pdb in the process. That's when I gave up and tried Python 2.7 to continue testing my plugin without having to deal any more with the error. (I had to close and reopen my terminal a couple times, so the actual pdb session is gone, unfortunately.)

(Incidentally, if you'd welcome a PR for my PBase plugin, I'll be happy to submit it once I figure out why it occasionally fails to find the image on image pages… or give up and accept the 1% failure rate.)

I believe this is fixed now with the latest commit, closing.