picar / pyrrd

Automatically exported from code.google.com/p/pyrrd
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

rrd.RRD takes empty lists as default argument values #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Subsequent calls to rrd.RRD will use previous values of ds and rra.

What is the expected output? What do you see instead?

Subesquent calls to rrd.RRD should all be independent of each other

What version of the product are you using? On what operating system?

Python 2.6.2, OS X

Please provide any additional information below.

Since the default argument value is only evaluated once, subsequent calls will 
use the previous 
value. See the discussion of this in the python docs, scroll down to 4.7.1 
"Important warning":

http://docs.python.org/tutorial/controlflow.html

Attached is a patch which follows the recommendations in the Python docs.

Original issue reported on code.google.com by smagis...@gmail.com on 13 Sep 2009 at 4:09

Attachments:

GoogleCodeExporter commented 9 years ago
I added some unit tests in pyrrd/tests/test_rrd.py for this.

Would you mind updating this ticket with another patch? One that passes with 
your
change, but fails against current trunk? Feel free to use/update
pyrrd.tests.test_rrd.RRDTestCase.test_creationDSsAndRRAs. Or add a new test 
method if
you prefer.

Thanks!

Original comment by duncan.m...@gmail.com on 28 Oct 2009 at 12:16

GoogleCodeExporter commented 9 years ago

Original comment by duncan.m...@gmail.com on 29 Oct 2009 at 5:53

GoogleCodeExporter commented 9 years ago
Although I agree with the truth of empty lists being problematic in method 
calls, I
haven't experienced any problems with it in this case. The unit tests that I 
wrote to
check if there was a problem are all currently passing.

In all likelihood, I'm missing an edge case, and would love to receive a patch 
for
the unit tests that shows a breakage.

Until then, I'll set the priority of this ticket to low...

Original comment by duncan.m...@gmail.com on 29 Oct 2009 at 8:53

GoogleCodeExporter commented 9 years ago

Original comment by duncan.m...@gmail.com on 18 Dec 2009 at 7:45

GoogleCodeExporter commented 9 years ago
In the course of fixing issue #18, I was able to create a test case that 
revealed
this bug :-) The fix was committed in bzr revno 123, svn r145.

Original comment by duncan.m...@gmail.com on 19 Dec 2009 at 8:32