Cannot create a HCondition with phrase=None

Bug #356253 reported by Matt Goodall
4
Affects Status Importance Assigned to Milestone
Hypy
Fix Released
Low
Cory Dodt

Bug Description

HCondition's __init__ is decorated with a unicodeToByte decorator and therefore calls enforceUnicode to check any positional or keyword args. Unfortunately, that means you cannot do HCondition(phrase=phrase) either, where 'phrase' may be None.

It would be nice if ensureUnicode is conditionally called, e.g. for non-None args or the result of a "should I call ensureUnicode" function.

Note, It's an easy problem to work around but it's does make for slightly unintuitive code:

args = {}
if phrase:
    args['phrase'] = phrase
cond = HCondition(**args)

Revision history for this message
Cory Dodt (corydodt) wrote :

Looks like HDatabase.remove has the same potential issue.

Changed in hypy:
assignee: nobody → corydodt
status: New → Confirmed
Revision history for this message
Cory Dodt (corydodt) wrote :

Committed a change to pass None straight through for unicodeToByte. It's mainly byte strings I'm concerned about, explicit Nones should not be a problem.

Changed in hypy:
importance: Undecided → Low
status: Confirmed → Fix Committed
Revision history for this message
Matt Goodall (matt-goodall) wrote :

Works for me, thanks.

Cory Dodt (corydodt)
Changed in hypy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.