Repository navigation
Issue 6736 - Exception thrown by dsconf instance repl get_ruv - #6742
Conversation
|
test_ruv_url_not_added_if_different_uuid is still failing! 😞 |
|
Ok. the problem is that None is expected when there is no default rather than KeyError ... |
| def get(self, key, vdef=None): | ||
| try: | ||
| return self[key] | ||
| except KeyError: | ||
| return vdef | ||
|
|
There was a problem hiding this comment.
I have a concern that now .get() and .__getitem__() have different behaviour. One raises a KeyError, and another one returns None/vdef.
Personally, I'd change get() to (and then, adapt the usage everywhere it's needed):
nkey = NormalizedRidDict.normalize_rid(key)
return super().get(nkey, vdef)
But I don't have a hard opinion here. We can go either way for NormalizedRidDict.
There was a problem hiding this comment.
This behavior difference also exists when using plain dict.
I agree that it is a bit confusing as I blindly fall into that pitfall ! 😉
But that is the way python implemented dict:
[src]$cat dict.py
d = { 'a':'b' }
print( d.get('k') )
try:
print( d['k'] )
except KeyError:
print("d['k'] raised KeyError")
try:
print( d.__getitem__('k') )
except KeyError:
print("d.__getitem__('k') raised KeyError")
[src]$python3 dict.py
None
d['k'] raised KeyError
d.__getitem__('k') raised KeyError
[src]$
There was a problem hiding this comment.
Okay, never mind...
Looks like it's by design! Oh, well
…6742) After issue 389ds#6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: 389ds#6736 Relates: 389ds#6715 Reviewed by: @droideck (Thanks!)
After issue #6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: #6736 Relates: #6715 Reviewed by: @droideck (Thanks!) (cherry picked from commit 64b2514)
After issue #6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: #6736 Relates: #6715 Reviewed by: @droideck (Thanks!) (cherry picked from commit 64b2514)
After issue #6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: #6736 Relates: #6715 Reviewed by: @droideck (Thanks!) (cherry picked from commit 64b2514)
After issue #6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: #6736 Relates: #6715 Reviewed by: @droideck (Thanks!) (cherry picked from commit 64b2514)
After issue #6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: #6736 Relates: #6715 Reviewed by: @droideck (Thanks!) (cherry picked from commit 64b2514)
After issue #6715 commit dsconf instance replication get_ruv fails with error because by default NormalizedRidDict does not calling getitem as I expected. The solution is to overwrite the get function to do things properly. Issue: #6736 Relates: #6715 Reviewed by: @droideck (Thanks!) (cherry picked from commit 64b2514)
After issue #6715 commit
dsconf instance replication get_ruvfails with errorbecause by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.
Issue: #6736
Relates: #6715
Reviewed by: @droideck (Thanks!)