diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-06-07 00:07:59 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-06-07 00:08:29 +0100 |
commit | b6e710b0fc022e009f51ca644cbcaa48f5207997 (patch) | |
tree | fa70778d24b2a6181cc2b394edc58bd9f00159ed /scripts/ticket58.py | |
parent | 1888bf41c0dcdde6d6ef825393554121d88a69e1 (diff) | |
download | psycopg2-b6e710b0fc022e009f51ca644cbcaa48f5207997.tar.gz |
Fixed refcount bug in copy_to() and copy_expert() methods too
Diffstat (limited to 'scripts/ticket58.py')
-rw-r--r-- | scripts/ticket58.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/scripts/ticket58.py b/scripts/ticket58.py index 86cabac..95520c1 100644 --- a/scripts/ticket58.py +++ b/scripts/ticket58.py @@ -42,13 +42,29 @@ cur = conn.cursor() gc_thread.start() # Now do lots of "cursor.copy_from" calls: +print "copy_from" for i in range(1000): f = StringIO("42\tfoo\n74\tbar\n") cur.copy_from(f, 'test', columns=('num', 'data')) # Assuming the other thread gets a chance to run during this call, expect a # build of python (with assertions enabled) to bail out here with: # python: Modules/gcmodule.c:277: visit_decref: Assertion `gc->gc.gc_refs != 0' failed. - + +# Also exercise the copy_to code path +print "copy_to" +cur.execute("truncate test") +f = StringIO("42\tfoo\n74\tbar\n") +cur.copy_from(f, 'test', columns=('num', 'data')) +for i in range(1000): + f = StringIO() + cur.copy_to(f, 'test', columns=('num', 'data')) + +# And copy_expert too +print "copy_expert" +cur.execute("truncate test") +for i in range(1000): + f = StringIO("42\tfoo\n74\tbar\n") + cur.copy_expert("copy test to stdout", f) # Terminate the GC thread's loop: done = 1 |