mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-10 19:16:34 +03:00
Added test for refcounting/gc bug reported by Michael Tharp
This commit is contained in:
parent
e8286084e9
commit
0a33ed01f5
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
@ -170,6 +170,9 @@
|
|||
<None Include="doc\src\tools\stitch_text.py" />
|
||||
<None Include="doc\src\_static\psycopg.css" />
|
||||
<None Include="doc\src\faq.rst" />
|
||||
<None Include="tests\test_async.py" />
|
||||
<None Include="tests\test_copy.py" />
|
||||
<None Include="tests\bug_gc.py" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="psycopg\adapter_asis.c" />
|
||||
|
|
31
tests/bug_gc.py
Executable file
31
tests/bug_gc.py
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
import time
|
||||
import unittest
|
||||
import gc
|
||||
|
||||
import sys
|
||||
if sys.version_info < (3,):
|
||||
import tests
|
||||
else:
|
||||
import py3tests as tests
|
||||
|
||||
class StolenReferenceTestCase(unittest.TestCase):
|
||||
def test_stolen_reference_bug(self):
|
||||
def fish(val, cur):
|
||||
gc.collect()
|
||||
return 42
|
||||
conn = psycopg2.connect(tests.dsn)
|
||||
UUID = psycopg2.extensions.new_type((2950,), "UUID", fish)
|
||||
psycopg2.extensions.register_type(UUID, conn)
|
||||
curs = conn.cursor()
|
||||
curs.execute("select 'b5219e01-19ab-4994-b71e-149225dc51e4'::uuid")
|
||||
curs.fetchone()
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user