Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttype referenced before assignment #97

Open
louwers opened this issue Jan 5, 2020 · 9 comments
Open

ttype referenced before assignment #97

louwers opened this issue Jan 5, 2020 · 9 comments

Comments

@louwers
Copy link

louwers commented Jan 5, 2020

            if rel_p.startswith('http'):

                img = rel_p
                local_filename, headers = urllib.request.urlretrieve(rel_p)
                size = ImageHandler.get_image_size(local_filename)
                if size:
                    w, h, ttype = size

                    FMT = u'''
                        <img src="data:image/{}" class="centerImage" {}>
                    '''
                img = ttype + ";base64," + get_as_base64(img)
@Derpius
Copy link

Derpius commented May 13, 2020

From that code snippet, I'd assume that you're not assigning anything to ttype prior to if size:?
If not then if if size: returns false, ttype never gets assigned, and there is no check if it's None before trying to use it when assigning img

@louwers
Copy link
Author

louwers commented May 13, 2020

Yup, that's the problem.

@Derpius
Copy link

Derpius commented May 13, 2020

Happy to help.


Please close the issue yourself by pressing the close issue button, as the developer of this plugin appears to be inactive (no commits since two years ago, no resolved issues since around the same time etc.)

@louwers
Copy link
Author

louwers commented May 13, 2020

I'll close it when it's fixed.

@Derpius
Copy link

Derpius commented May 13, 2020

Can you program in python and fix it yourself? If not then it wont get fixed because, as per my previous comment, the developer has been inactive for around 2 years.

@Derpius
Copy link

Derpius commented May 13, 2020

I could probably fix it if you're unable to if it's a pressing issue

@louwers
Copy link
Author

louwers commented May 13, 2020

Then I'll wait until he rises again. :-)

@Derpius
Copy link

Derpius commented May 13, 2020

if rel_p.startswith('http'):
    img = rel_p
    local_filename, headers = urllib.request.urlretrieve(rel_p)
    size = ImageHandler.get_image_size(local_filename)
    if size:
        w, h, ttype = size

        FMT = u'<img src="data:image/{}" class="centerImage" {}>'
        img = ttype + ";base64," + get_as_base64(img)

Fixed.
Don't know if it's gonna cause other errors elsewhere in the plugin as I can't test it at the moment.

@louwers
Copy link
Author

louwers commented May 13, 2020

OK I'll close the issue when it's merged.

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

No branches or pull requests

2 participants