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

Identity is not the same thing as equality in Python #1306

Merged
merged 1 commit into from May 8, 2019

Conversation

Projects
None yet
3 participants
@cclauss
Copy link
Contributor

commented May 8, 2019

Use ==/!= to compare str, bytes, and int literals: fmt is not 'raw' --> fmt != 'raw'

$ python

>>> raw = 'ra'
>>> raw += 'w'
>>> raw
'raw'
>>> raw == 'raw'
True
>>> raw is 'raw'
False
>>> 0 == 0.0
True
>>> 0 is 0.0
False

Pwntools Pull Request

Thanks for contributing to Pwntools! Take a moment to look at CONTRIBUTING.md to make sure you're familiar with Pwntools development.

Please provide a high-level explanation of what this pull request is for.

Testing

Pull Requests that introduce new code should try to add doctests for that code. See TESTING.md for more information.

Target Branch

Depending on what the PR is for, it needs to target a different branch.

You can always change the branch after you create the PR if it's against the wrong branch.

Branch Type of PR
dev New features, and enhancements
dev Documentation fixes and new tests
stable Bug fixes that affect the current stable branch
beta Bug fixes that affect the current beta branch, but not stable
dev Bug fixes for code that has never been released
Identity is not the same thing as equality in Python
Use ==/!= to compare str, bytes, and int literals: __fmt is not 'raw'__ --> __fmt != 'raw'__

$ __python__
```python
>>> raw = 'ra'
>>> raw += 'w'
>>> raw
'raw'
>>> raw == 'raw'
True
>>> raw is 'raw'
False
```
@Arusekk

This comment has been minimized.

Copy link
Collaborator

commented May 8, 2019

This should also be cherry-picked onto stable

@Arusekk Arusekk merged commit c15afc5 into Gallopsled:dev May 8, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on patch-3 at 58.506%
Details

@cclauss cclauss deleted the cclauss:patch-3 branch May 8, 2019

@zachriggle

This comment has been minimized.

Copy link
Contributor

commented May 8, 2019

jasperla added a commit to jasperla/pwntools that referenced this pull request May 8, 2019

Identity is not the same thing as equality in Python (Gallopsled#1306)
Use ==/!= to compare str, bytes, and int literals: __fmt is not 'raw'__ --> __fmt != 'raw'__

$ __python__
```python
>>> raw = 'ra'
>>> raw += 'w'
>>> raw
'raw'
>>> raw == 'raw'
True
>>> raw is 'raw'
False
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.