New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cremona_letter_code does not handle erroneous input gracefully. #10105
Comments
comment:2
You are quite right: any input not a non-negative integer is bad, and the code should check this. It's also true that this function need not be in the global namespace, it's a technical helper function. so in sage/databases/all.py:
only the first import should be there. For another ticket perhaps, since certainly removing those global imports will result in lots of local ones being needed. |
comment:3
Replying to @JohnCremona:
I thought I probably was, though since I'm not a mathematician, I don't understand much of this. I just wrote a little script which stuck some data into every function and looked to see for any that crashed or hung - I've no idea if the output of the others is correct or not.
Yes, those other changes do sound like they need to be on another ticket. I'll leave you to create that one. I would have thought this one pretty easy to fix, though I'm not going to attempt it myself as I'm not a competent Python programmer. You are the best person to do it. Dave |
Changed keywords from none to databases |
Author: John Cremona |
comment:4
Attachment: trac_10105-cremona-letter-code.patch.gz Here's a patch + tests. |
comment:5
I'll test the patch. A minor point, but there is a grammatical error - the word are is missing. Cremona letter codes are only defined for non-negative integers Dave |
comment:6
I've not downloaded the latest alpha3 yet, and since I'm using my alpha2 for testing, I will need some time to download the alpha3 and will test with that. Dave |
comment:7
Replying to @sagetrac-drkirkby:
That was an abbreviated message rather than a mistake, but I have corrected it now. By the way, the only places where this function is used outside its own file are in modular/abvar/abvar and .../abvar_newform, where it is explicitly imported. |
updated for grammar correction |
comment:8
Attachment: trac_10105-cremona-letter-code.2.patch.gz John, it does not check if the input is an integer or not - it gives an output for a floating point number too. I would hope it would generate an error message for that too.
|
comment:9
Hmmm. Is there a better way to test this than
? |
replaces all previous |
comment:10
Attachment: trac_10105-cremona-letter-code.3.patch.gz Third attempt! |
Reviewer: David Kirkby |
comment:11
Thanks John. I think its third time lucky, as I can't find any faults with this. I've tried every combination of junk I can think of to throw at It passes the doctest
However, I don't feel my Python skills are sufficient to press the positive review, so I hope someone with more Python knowledge will look at this. But I can't fault it myself. |
comment:12
I'm having a look. |
Changed reviewer from David Kirkby to David Kirkby, Jeroen Demeyer |
Attachment: trac_10105-cremona-letter-code.4.patch.gz Removed "pass", replaces previous patches |
comment:13
I removed the unneeded "pass" statement. Apart from that, everything look fine. |
comment:14
Replying to @jdemeyer:
Thanks -- I rearranged the code several times and that "pass" got left in my mistake. |
Merged: sage-4.6.1.alpha0 |
Although I'm not a mathematician, I believe from reading the help page and looking at the examples, the Sage command
cremona_letter_code
should probably only work for non-negative integers. However, this is not the case.Any attempt to send erroneous input to a command should generate an error message.
There seems to be three problems with this.
This was found by using Fuzz Testing
http://en.wikipedia.org/wiki/Fuzz_testing
where one purposely supplies invalid input, to check how software behaves.
http://www.ibm.com/developerworks/java/library/j-fuzztest.html
says Fuzz testing is a simple technique that can have a profound effect on your code quality.
I've marked it as a minor priority, as clearly its not a huge bug. But it would be worth fixing it.
Dave
Component: elliptic curves
Keywords: databases
Author: John Cremona
Reviewer: David Kirkby, Jeroen Demeyer
Merged: sage-4.6.1.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/10105
The text was updated successfully, but these errors were encountered: