[DB-SIG] PEP 249 .Binary() function incorrect for Python 3.0 ?

M.-A. Lemburg mal at egenix.com
Tue Feb 3 14:30:22 CET 2009


On 2009-02-02 23:59, Vernon Cole wrote:
> Marc-Andre;
>   So, to clarify:  You are saying that it is acceptable for a Python 3.0
> implementation
> to raise an error when .Binary() receives a unicode string.  It should
> expect a b'xxx binary string here xxx' type.
>   Is that correct?

Again, that's up to the constructor. It could e.g. accept Unicode if
it's all ASCII or contains a hex/base64 representation of the binary
data.

However, it certainly makes sense to just alias Binary to the bytes
type constructor for simplicity.

> --
> Vernon
> 
> On Mon, Feb 2, 2009 at 10:01 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> 
>> On 2009-02-02 17:34, Vernon Cole wrote:
>>> 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".
>> That's not entirely correct: the return type of Binary() is not defined
>> by the spec, only the fact that a binary string must be acceptable as
>> input type. In Python 2, this is str(), in Python 3, bytes().
>>
>> The output type of Binary() is module specific, since different modules
>> may need different types.
>>
>> --
>> Marc-Andre Lemburg
>> eGenix.com
>>
>> Professional Python Services directly from the Source  (#1, Feb 02 2009)
>>>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
>> ________________________________________________________________________
>>
>> ::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
>>
>>
>>   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>>    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>>           Registered at Amtsgericht Duesseldorf: HRB 46611
>>               http://www.egenix.com/company/contact/
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> DB-SIG maillist  -  DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Feb 03 2009)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the DB-SIG mailing list