4 # Copyright (C) 2011 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Script for testing for an issue in PycURL"""
34 ("PycURL 7.19.0 added a new function named \"reset\" on \"pycurl.Curl\""
35 " objects to release all references to other resources. Unfortunately that"
36 " version contains a bug with reference counting on the \"None\" singleton,"
37 " leading to a crash of the Python interpreter after a certain amount of"
38 " performed requests. Your system uses a version of PycURL affected by this"
39 " issue. A patch is available at [1]. A detailed description can be found"
42 ("[1] http://sf.net/tracker/?"
43 "func=detail&aid=2893665&group_id=28236&atid=392777\n"),
44 "[2] https://bugzilla.redhat.com/show_bug.cgi?id=624559",
48 class TestPyCurlReset(unittest.TestCase):
50 start_refcount = sys.getrefcount(None)
51 abort_refcount = int(start_refcount * 0.8)
53 assert start_refcount > 100
58 except AttributeError:
61 for i in range(start_refcount * 2):
63 # The bug can be detected if calling "reset" several times continously
64 # reduces the number of references
65 if sys.getrefcount(None) < abort_refcount:
66 print >>sys.stderr, "#" * 78
68 print >>sys.stderr, textwrap.fill(line, width=78)
69 print >>sys.stderr, "#" * 78
73 if __name__ == "__main__":
74 testutils.GanetiTestProgram()