Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call to api.fb_interpret gives a type error, expected LP_LP_c_long instance instead of LP_c_long [PYFB59] #76

Closed
firebird-automations opened this issue Oct 8, 2015 · 2 comments

Comments

@firebird-automations
Copy link

Submitted by: Sam Watkins (sswam)

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.

@firebird-automations
Copy link
Author

Commented by: Sam Watkins (sswam)

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)

@firebird-automations
Copy link
Author

Modified by: @pcisar

status: Open [ 1 ] => Closed [ 6 ]

resolution: Cannot Reproduce [ 5 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants