Some users have usernames, but not names on GitHub (like @rileyjshaw used to).
On commit--blog, everywhere there should be a name, I do
user.name or user.username. If name is
None, it'll fall back on their username, which must exist.
That pattern now pops up in a bunch of places so a better fix would be to add a method to the user object to just get the appropriate one. So this isn't a very good fix but I'm lazy.
This commit should fix #24, however. In that case a string was being concatenated to the username with the
+ operator, something like:
greeting = 'hello ' + user.name or user.username
This doen't work at all when
None, because in python, the
+ operator has a higher precedence than the
or operator. So it's effectively doing:
greeting = ('hello ' + user.name) or user.username
... which is clearly not the desired effect, and moreover string concatenation with
None is illegal so it breaks.
The quick fix here is to force precedence with parens, like:
greeting = 'hello ' + (user.name or user.username)
though maybe string concatenation is a poor patern and I should have done string formatting. Whatever.