Issue Details (XML | Word | Printable)

Key: PYFB-59
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Pavel Cisar
Reporter: Sam Watkins
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird driver for Python

call to api.fb_interpret gives a type error, expected LP_LP_c_long instance instead of LP_c_long

Created: 08/Oct/15 02:12 AM   Updated: 11/Nov/15 01:46 PM
Component/s: None
Affects Version/s: 1.4.9, 1.4.10
Fix Version/s: None

Environment: ubuntu 14.04.2, linux 3.13 64 bit, python 2.7.6


 Description  « Hide
Module fdb.fbcore:542 in exception_from_status
<< while True:
               result = api.fb_interpret(msg, 512, pvector)
               if result != 0:
                   if PYTHON_MAJOR_VER == 3:
>> result = api.fb_interpret(msg, 512, pvector)
ArgumentError: argument 3: <type 'exceptions.TypeError'>: expected LP_LP_c_long instance instead of LP_c_long

It looks like fb_interpret expects a pointer to pvector.

I'm not sure how to reproduce this yet, it happened in dev version of our webapp today.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sam Watkins added a comment - 30/Oct/15 03:55 AM
ctypes should be able to convert these types automatically, and like PYFB26 the bug only occurs occasionally, and I only saw it when running under apache2 / mod_wsgi.

I "hacked around" this problem with the following changes, and have not seen the bug recur with the hacks. But this is not a good solution.

./fdb/fbcore.py:
    145c145
    < XSQLVAR, ISC_TEB, RESULT_VECTOR, ISC_STATUS, ISC_STATUS_ARRAY,
    ISC_STATUS_PTR,
    ---
    > XSQLVAR, ISC_TEB, RESULT_VECTOR, ISC_STATUS, ISC_STATUS_ARRAY,
    ISC_STATUS_PTR, ISC_STATUS_PTR_PTR,
    539a540,541
    > # pvector_ptr = ctypes.byref(pvector)
    > pvector_ptr = ctypes.cast(ctypes.addressof(pvector), ISC_STATUS_PTR_PTR)
    542c544,548
    < result = api.fb_interpret(msg, 512, pvector)
    ---
    > # SOMETIMES this was causing an error is using pvector rather than a pointer
    to it
    > # ctypes is supposed to do auto-byref, but sometimes gave
    > # <type 'exceptions.TypeError'>: expected LP_LP_c_long instance instead of
    LP_c_long>
    > # result = api.fb_interpret(msg, 512, pvector)
    > result = api.fb_interpret(msg, 512, pvector_ptr)

./fdb/ibase.py:
    880a881
    > ISC_STATUS_PTR_PTR = POINTER(ISC_STATUS_PTR)