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

[py3] Fix SyntaxWarnings #676

Merged
merged 2 commits into from
Jan 18, 2020
Merged

[py3] Fix SyntaxWarnings #676

merged 2 commits into from
Jan 18, 2020

Conversation

nicfit
Copy link
Contributor

@nicfit nicfit commented Jan 17, 2020

/home/travis/devel/exaile/xlgui/preferences/collection.py:37:
SyntaxWarning: "is not" with a literal. Did you mean "!="?
  return [v.lower() for v in default_strip_list.split(' ') if v is not '']
/home/travis/devel/exaile/xlgui/preferences/collection.py:54:
SyntaxWarning: "is not" with a literal. Did you mean "!="?
  values = [v.lower() for v in self.widget.get_text().split(' ') if v is not '']

@genodeftest
Copy link
Member

Nice catch, thank you!

Does this mean the second line of this code is also wrong?

except Exception:
    if field is 'tracknumber':
        temp.set_tag_raw('tracknumber', [0], notify_changed=False)

Source: https://github.com/exaile/exaile/blob/py3/plugins/daapclient/__init__.py#L569

@nicfit
Copy link
Contributor Author

nicfit commented Jan 17, 2020

I did some grepping but did not catch that one in daapclient.. but that's the same and will SyntaxWarn if hit.

@nicfit
Copy link
Contributor Author

nicfit commented Jan 17, 2020

@genodeftest Fixed that one too.

Copy link
Member

@genodeftest genodeftest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

For explanation, if someone else is interested: is does identity comparison, == does value comparison. Two strings with identical letters (value) may have different identity, so the old implementation was actually wrong (but probably worked due to some backward compatibility stuff or because python just tolerates everything^^).
Example: https://www.thecoderpedia.com/blog/python-string-comparison/

@genodeftest genodeftest merged commit 0488ed8 into exaile:py3 Jan 18, 2020
@nicfit nicfit deleted the syntaxwarnings branch January 18, 2020 17:10
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

Successfully merging this pull request may close these issues.

None yet

2 participants