Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions adodbapi/adodbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ def getIndexedValue(obj, index):

from collections.abc import Mapping

# --- define objects to smooth out Python3000 <-> Python 2 differences
unicodeType = str
longType = int
StringTypes = str
maxint = sys.maxsize


# ----------------- The .connect method -----------------
def make_COM_connecter():
Expand Down Expand Up @@ -167,7 +161,7 @@ def _configure_parameter(p, value, adotype, settings_known):
p.Size = len(value)
p.AppendChunk(value)

elif isinstance(value, StringTypes): # v2.1 Jevon
elif isinstance(value, str): # v2.1 Jevon
L = len(value)
if adotype in api.adoStringTypes: # v2.2.1 Cole
if settings_known:
Expand Down
24 changes: 5 additions & 19 deletions adodbapi/apibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@

verbose = False # debugging flag

# --- define objects to smooth out Python3 <-> Python 2 differences
unicodeType = str
longType = int
StringTypes = str
makeByteBuffer = bytes
memoryViewType = memoryview
_BaseException = Exception

try: # jdhardy -- handle bytes under Py3
bytes
except NameError:
bytes = str # define it for old Pythons


# ------- Error handlers ------
def standardErrorHandler(connection, cursor, errorclass, errorvalue):
Expand All @@ -45,8 +32,7 @@ def standardErrorHandler(connection, cursor, errorclass, errorvalue):
raise errorclass(errorvalue)


# Note: _BaseException is defined differently between Python 2 and 3
class Error(_BaseException):
class Error(Exception):
pass # Exception that is the base class of all other error
# exceptions. You can use this to catch all errors with one
# single 'except' statement. Warnings are not considered
Expand All @@ -55,7 +41,7 @@ class Error(_BaseException):
# module exceptions).


class Warning(_BaseException):
class Warning(Exception):
pass


Expand Down Expand Up @@ -153,7 +139,7 @@ class FetchFailedError(OperationalError):
#
# def Binary(aString):
# """This function constructs an object capable of holding a binary (long) string value. """
# b = makeByteBuffer(aString)
# b = bytes(aString)
# return b
# ----- Time converters ----------------------------------------------
class TimeConverter(object): # this is a generic time converter skeleton
Expand Down Expand Up @@ -413,7 +399,7 @@ def __ne__(self, other):

# ------- utilities for translating python data types to ADO data types ---------------------------------
typeMap = {
memoryViewType: adc.adVarBinary,
memoryview: adc.adVarBinary,
float: adc.adDouble,
type(None): adc.adEmpty,
str: adc.adBSTR,
Expand All @@ -435,7 +421,7 @@ def pyTypeToADOType(d):
if tp in dateconverter.types:
return adc.adDate
# otherwise, attempt to discern the type by probing the data object itself -- to handle duck typing
if isinstance(d, StringTypes):
if isinstance(d, str):
return adc.adBSTR
if isinstance(d, numbers.Integral):
return adc.adBigInt
Expand Down
20 changes: 7 additions & 13 deletions adodbapi/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import adodbapi.process_connect_string
from adodbapi.apibase import ProgrammingError

_BaseException = api._BaseException

sys.excepthook = Pyro4.util.excepthook
Pyro4.config.PREFER_IP_VERSION = 0 # allow system to prefer IPv6
Pyro4.config.COMMTIMEOUT = 40.0 # a bit longer than the default SQL server Gtimeout
Expand All @@ -58,16 +56,12 @@
if verbose:
print(version)

# --- define objects to smooth out Python3 <-> Python 2 differences
unicodeType = str # this line will be altered by 2to3.py to '= str'
longType = int # this line will be altered by 2to3.py to '= int'
StringTypes = str
makeByteBuffer = bytes
memoryViewType = memoryview

# -----------------------------------------------------------
# conversion functions mandated by PEP 249
Binary = makeByteBuffer # override the function from apibase.py
def Binary(aString):
"""This function constructs an object capable of holding a binary (long) string value."""
return bytes(aString)


def Date(year, month, day):
Expand Down Expand Up @@ -164,7 +158,7 @@ def connect(*args, **kwargs): # --> a remote db-api connection object
raise api.DatabaseError(
"Pyro error creating connection to/thru=%s" % repr(kwargs)
)
except _BaseException as e:
except Exception as e:
raise api.DatabaseError(
"Error creating remote connection to=%s, e=%s, %s"
% (repr(kwargs), repr(e), sys.exc_info()[2])
Expand Down Expand Up @@ -364,7 +358,7 @@ def fixpickle(x):
# for 'named' paramstyle user will pass a mapping
newargs = {}
for arg, val in list(x.items()):
if isinstance(val, memoryViewType):
if isinstance(val, memoryview):
newval = array.array("B")
newval.fromstring(val)
newargs[arg] = newval
Expand All @@ -374,7 +368,7 @@ def fixpickle(x):
# if not a mapping, then a sequence
newargs = []
for arg in x:
if isinstance(arg, memoryViewType):
if isinstance(arg, memoryview):
newarg = array.array("B")
newarg.fromstring(arg)
newargs.append(newarg)
Expand Down Expand Up @@ -565,7 +559,7 @@ def callproc(self, procname, parameters=None):
def fetchone(self):
try:
f1 = self.proxy.crsr_fetchone(self.id)
except _BaseException as e:
except Exception as e:
self._raiseCursorError(api.DatabaseError, e)
else:
if f1 is None:
Expand Down
15 changes: 6 additions & 9 deletions adodbapi/remote/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
import adodbapi.apibase as api
import adodbapi.process_connect_string

makeByteBuffer = bytes
_BaseException = Exception
Binary = bytes
try:
pyro_host = os.environ["PYRO_HOST"]
except:
Expand All @@ -63,25 +60,25 @@
if arg.lower().startswith("host"):
try:
pyro_host = arg.split("=")[1]
except _BaseException:
except Exception:
raise TypeError('Must supply value for argument="%s"' % arg)

if arg.lower().startswith("port"):
try:
pyro_port = int(arg.split("=")[1])
except _BaseException:
except Exception:
raise TypeError('Must supply numeric value for argument="%s"' % arg)

if arg.lower().startswith("timeout"):
try:
PYRO_COMMTIMEOUT = int(arg.split("=")[1])
except _BaseException:
except Exception:
raise TypeError('Must supply numeric value for argument="%s"' % arg)

if arg.lower().startswith("--verbose"):
try:
verbose = int(arg.split("=")[1])
except _BaseException:
except Exception:
raise TypeError('Must supply numeric value for argument="%s"' % arg)
adodbapi.adodbapi.verbose = verbose
else:
Expand Down Expand Up @@ -118,15 +115,15 @@ def unfixpickle(x):
newargs = {}
for arg, val in list(x.items()):
if isinstance(arg, array.array):
newargs[arg] = Binary(val)
newargs[arg] = bytes(val)
else:
newargs[arg] = val
return newargs
# if not a mapping, then a sequence
newargs = []
for arg in x:
if isinstance(arg, array.array):
newargs.append(Binary(arg))
newargs.append(bytes(arg))
else:
newargs.append(arg)
return newargs
Expand Down
3 changes: 0 additions & 3 deletions adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
from adodbapi import ado_consts


long = int


def randomstring(length):
return "".join([random.choice(string.ascii_letters) for n in range(32)])

Expand Down
Loading