Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#55 Mini-patch to use the new built-in set types in Python 2.6

open
Andy Dustman
MySQLdb (53)
5
2012-09-19
2008-11-19
No

Hi all!

I patched a few lines to make MySQLdb run without warnings on Python 2.6. All it took was to replace the imports of the deprecated "sets" module with the new built-in types.
Note that this change means that MySQLdb will no longer run on Python 2.5.
I also updated the ez_setup.py file to use the latest setuptools (0.6c9).

Regards,

Christian Blichmann

Discussion

  • Patch for running with Python 2.6

     
  • I would like to propose a small modification to this patch which will allow it to work also with previous python versions.
    Please see my version:
    $ diff -r MySQL-python-1.2.2{,-fb}
    diff -r MySQL-python-1.2.2/MySQLdb/converters.py MySQL-python-1.2.2-fb/MySQLdb/converters.py
    37c37,41
    < from sets import BaseSet, Set


    try:
    (set, frozenset)
    except NameError:
    from sets import ImmutableSet as frozenset
    from sets import Set as set
    45c49
    < return Set([ i for i in s.split(',') if i ])


    return set([ i for i in s.split(',') if i ])
    

    129c133
    < Set: Set2Str,


    set: Set2Str,
    

    diff -r MySQL-python-1.2.2/MySQLdb/init.py MySQL-python-1.2.2-fb/MySQLdb/init.py
    34,35c34,40
    < from sets import ImmutableSet
    < class DBAPISet(ImmutableSet):


    try:
    (set, frozenset)
    except NameError:
    from sets import ImmutableSet as frozenset
    from sets import Set as set

    class DBAPISet(frozenset):
    41,42c46
    < from sets import BaseSet
    < if isinstance(other, BaseSet):


        if isinstance(other, (set, frozenset)):
    

    48,49c52
    < from sets import BaseSet
    < if isinstance(other, BaseSet):


        if isinstance(other, (set, frozenset)):