[Merge] lp:~barry/apport/lp1566975 into lp:~ubuntu-core-dev/ubuntu/xenial/apport/ubuntu
Martin Pitt
martin.pitt at ubuntu.com
Thu Apr 7 08:44:19 UTC 2016
> You should also at least keep the second argument to the assert, so that the traceback will include the value of 'k'.
The bug report doesn't contain the actual error message/traceback you got, but I suppose it looked something like
$ python3 -c 'import apport; r=apport.Report(); r["a:b"] = "foo"'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/martin/ubuntu/apport/trunk/problem_report.py", line 644, in __setitem__
assert k.replace('.', '').replace('-', '').replace('_', '').isalnum()
AssertionError
I just committed http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/3071 which makes this more verbose:
AssertionError: key 'a:b' contains invalid characters (only numbers, letters, '.', '_', and '-' are allowed)
Thanks for the hint!
> I wonder if an assert is the right thing to do here. Generally assertions are for ensuring that internal logic is correct.
Hmm, a lot of software uses assertions to verify that its input arguments are correct, i. e. match the declared API. That's why I'm using assert here. In this case the package hook violates the spec, so I suppose an assertion exception is as good as any? But if you say that in Python bad input to methods should rather raise a ValueError I'm happy to change it.
--
https://code.launchpad.net/~barry/apport/lp1566975/+merge/291144
Your team Ubuntu Core Development Team is subscribed to branch lp:~ubuntu-core-dev/ubuntu/xenial/apport/ubuntu.
More information about the Ubuntu-reviews
mailing list