apple / apple/foundationdb

Python: `tr.get` returns something equals `None` but is not `None`

Open
#330 10 comments 0 reactions 1 assignee Claimed by @ajbeamon View on GitHub
Dominant language
C++
Stars
16.7k
Forks
1.6k
Avg merge
1d 20h
Merged PRs (30d)
126

Description

Here is an example code:

```python
@fdb.transactional
def get_score(tr, user):
"""Return the score of the user.

Add the user to the leaderboard if they are not already there

"""
user_key = pack(('scores', user))
score = tr.get(user_key)
if score == None: # XXX: this use == instead of is because `score` is not `None`
# init the score at zero
score = 0
tr.set(user_key, pack((score,)))
tr.set(pack(('leaderboard', score, user)), b'')
else:
score = unpack(score)[0]
return score
```

This is misleading. `tr.get(b'foobar)` must return `None` if `b'foobar'` is not there

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.