ContinuumIO / flask-ldap-login

Flask ldap integration
BSD 2-Clause "Simplified" License
105 stars 35 forks source link

Convert keymap filters to UTF-8 #11

Open ijstokes opened 9 years ago

ijstokes commented 9 years ago

Novartis discovered a problem with https://github.com/ContinuumIO/flask-ldap-login/blob/master/flask_ldap_login/__init__.py#L130 as noted here: https://continuumsupport.zendesk.com/agent/tickets/393

Their fix was to do:

return map(lambda s: s.encode('utf-8'), keymap.values()) # was: keymap.values() 

instead.

damianavila commented 9 years ago

As I said in FD, I would use a list comprehension to solve the issue... I feel it more pythonic, but this fix should work too...

tswicegood commented 9 years ago

:+1: to @damianavila's suggestion. return [s.encode('utf-8') for s in keymap.values()] reads much more cleanly in Python than map + lambda.

DavidMertz commented 9 years ago

A listcomp is fine, of course. But since 'utf-8' is the default encoding, the map could also be simplified to:

return map(str.encode, keymap.values())

That version looks non-ugly to me, and in fact more readable than the listcomp.