3939import sys
4040import threading
4141import datetime
42+ #from warnings import warn
4243from ctypes import memmove , memset , create_string_buffer , cast , byref , string_at , sizeof , \
4344 c_char_p , c_void_p , c_byte , c_ulong
44- from .types import Error , DatabaseError , InterfaceError , BCD , \
45+ from .types import Error , DatabaseError , InterfaceError , FirebirdWarning , BCD , \
4546 StateResult , DirectoryCode , BlobInfoCode , SQLDataType , XpbKind , \
4647 StatementType , StateFlag , CursorFlag , StatementFlag , PreparePrefetchFlag , get_timezone
4748from . import fbapi as a
@@ -67,7 +68,7 @@ class iVersionedMeta(type):
6768 def __call__ (cls : iVersioned , intf ):
6869 v = intf .contents .vtable .contents .version
6970 for c in cls .__mro__ :
70- if getattr (c , 'VERSION' , 0 ) = = v :
71+ if getattr (c , 'VERSION' , 0 ) < = v :
7172 return super (iVersionedMeta , iVersionedMeta ).__call__ (c , intf )
7273
7374# IVersioned(1)
@@ -76,9 +77,9 @@ class iVersioned(metaclass=iVersionedMeta):
7677 VERSION = 1
7778 def __init__ (self , intf ):
7879 self ._as_parameter_ = intf
79- if intf and self .vtable .version != self .VERSION : # pragma: no cover
80+ if intf and self .vtable .version < self .VERSION : # pragma: no cover
8081 raise InterfaceError (f"Wrong interface version { self .vtable .version } , expected { self .VERSION } " )
81- def __report (self , cls : Union [Error , Warning ], vector_ptr : a .ISC_STATUS_ARRAY_PTR ) -> None :
82+ def __report (self , cls : Union [Error , FirebirdWarning ], vector_ptr : a .ISC_STATUS_ARRAY_PTR ) -> None :
8283 msg = _util .format_status (self .status )
8384 sqlstate = create_string_buffer (6 )
8485 a .api .fb_sqlstate (sqlstate , vector_ptr )
@@ -103,7 +104,9 @@ def _check(self) -> None:
103104 if StateFlag .ERRORS in state :
104105 raise self .__report (DatabaseError , self .status .get_errors ())
105106 if StateFlag .WARNINGS in state : # pragma: no cover
106- raise self .__report (Warning , self .status .get_warning ())
107+ raise self .__report (FirebirdWarning , self .status .get_warning ())
108+ #warn(self.__report(FirebirdWarning, self.status.get_warning()).args[0],
109+ #FirebirdWarning, 2)
107110 @property
108111 def status (self ) -> iStatus :
109112 "iStatus for interface"
0 commit comments