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

Pipfile.lock() is not idempotent #125

Open
GPHemsley opened this issue May 1, 2020 · 0 comments
Open

Pipfile.lock() is not idempotent #125

GPHemsley opened this issue May 1, 2020 · 0 comments

Comments

@GPHemsley
Copy link

GPHemsley commented May 1, 2020

pipfile/pipfile/api.py

Lines 128 to 133 in 7d7c312

def lock(self):
"""Returns a JSON representation of the Pipfile."""
data = self.data
data['_meta']['hash'] = {"sha256": self.hash}
data['_meta']['pipfile-spec'] = 6
return json.dumps(data, indent=4, separators=(',', ': '))

Because line 130 is not using copy to copy self.data, the subsequent lines are mutating self.data, which is adding self.hash to the value self.data.

This causes every subsequent call to Pipfile.lock() to hash the hash, which means the hash changes every time.

import pipfile

p = pipfile.load("Pipfile")

hash_before = p.hash
print(hash_before)

p.lock()

hash_after = p.hash
print(hash_after)

print(hash_before == hash_after)
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

1 participant