Hello, everyone:

Work has gone well in porting adodbapi to work in Python 3.0. The result
should be posted in a beta version in pywin32 v.213 real soon now.
I have patched the standards compliance test as discussed earlier in this
forum.
There is one last error I am getting, but I believe that should be left
intact, as a protection when porting to 3.0.

The PEP says:
>
> Binary(string)
>
> This function constructs an object capable of holding a
> binary (long) string value.

Given that Python 3.0 no longer uses a string for this purpose, the routine
should really accept an object of data type "byte".

My 3.0 ready code looks like this:
<Python>

> if sys.version[0] == '3':
>     makeByteBuffer = bytes
> else:
>     makeByteBuffer = buffer


 def Binary(aString):
>     """This function constructs an object capable of holding a binary
> (long) string value. """
>     return makeByteBuffer(aString)

 </Python>

The python 3.0 built in function "bytes" insists that, if it is fed a
unicode string, it must also have an encoding.
So when I run the compliance test, I get:

> C:\adodbapi_225\adodbapi30\tests>test_adodbapi_dbapi20.py
> This module depends on the dbapi20 compliance tests created by Stuart
> Bishop
> (see db-sig mailing list history for info)
> adodbapi v2.2.5
> Tested with dbapi20 1.1.1.1.2.1
>     ...Testing MS-SQL login...
> ..E.................................
> ======================================================================
> ERROR: test_Binary (__main__.test_adodbapi)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "C:\adodbapi_225\adodbapi30\tests\dbapi20.py", line 835, in
> test_Binary
>     b = self.driver.Binary('Something')
>   File "C:\adodbapi_225\adodbapi30\adodbapi.py", line 972, in Binary
>     return makeByteBuffer(aString)
> TypeError: string argument without an encoding
>
> ----------------------------------------------------------------------
> Ran 36 tests in 14.208s
>
> FAILED (errors=1)
>

IMHO, in Python 3.0, this is exactly what should happen, so that the
programmer will be aware that the interface has changed.

What do you all think?
--
Vernon Cole
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to