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

#87 TypeError: object does not support item assignment

MySQLdb-1.0
closed
Andy Dustman
MySQLdb (285)
1
2014-03-03
2004-06-10
perica
No

On FreeBSD 4.9 with:
- python 2.3.4,
- apache 2.0.49,
- mod_python 3.1.3
- mysql Ver 11.18 Distrib 3.23.58, for portbld-
freebsd4.9 (i386)

this code:

import MySQLdb
db = MySQLdb.connect(host="localhost", user="joe",
passwd="secret",
db="my_db")


results with this error:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/site-
packages/MySQLdb/init.py", line 64, in Connect
return apply(Connection, args, kwargs)
File "/usr/local/lib/python2.3/site-
packages/MySQLdb/connections.py", line 117, in init
self.converter[types.StringType] = self.string_literal
TypeError: object does not support item assignment


Discussion

1 2 > >> (Page 1 of 2)
  • beat birkhofer
    beat birkhofer
    2004-06-11

    Logged In: YES
    user_id=302344

    Happens with

    Python 2.3.4 (#1, May 30 2004, 13:16:44)
    [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin

    mysql Ver 12.22 Distrib 4.0.18, for apple-darwin7.3.0 (powerpc)

    on MacOSX 10.3.4

    (but does not happen with python 2.2/mysql 4.0.17/MacOSX 10.2.8)

     
  • Andy Dustman
    Andy Dustman
    2004-06-12

    Logged In: YES
    user_id=71372

    In connections.Connection.init, try inserting this line
    immediately before the line that is raising the exception:

    print 'conv = ', kwargs2['conv']

    This should be a dictionary (normally).

     
  • beat birkhofer
    beat birkhofer
    2004-06-12

    Logged In: YES
    user_id=302344

    kwargs2['conv']:

    conv = {0: <type 'float'="">, 1: <type 'int'="">, 2: <type 'int'="">, 3: <type 'long'="">, <type 'tuple'="">: <built-in function="" escape_sequence="">, 5: <type 'float'="">, 7: <function mysql_timestamp_converter="" at="" 0x38fef0="">, 8: <type 'long'="">, 9:
    <type 'int'="">, 10: <function Date_or_None="" at="" 0x38faf0="">, 11:
    <function Time_or_None="" at="" 0x38f730="">, 12: <function DateTime_or_None="" at="" 0x38f6b0="">, 13: <type 'int'="">, <type 'float'="">: <function Float2Str="" at="" 0x398930="">, 252: [(128,
    <function char_array="" at="" 0x398a30="">), (None, <function <lambda=""> at 0x398eb0>), (None, None)]
    , <type 'int'="">:
    <function Thing2Str="" at="" 0x394cb0="">, 4: <type 'float'="">, <type 'array.array'="">: <function array2Str="" at="" 0x398a70="">, <type 'NoneType'="">: <function None2NULL="" at="" 0x398970="">, <type 'instance'="">: <function Instance2Str="" at="" 0x3989f0="">, <type 'dict'="">: <built-in function="" escape_dict="">, <type 'unicode'="">:
    <function Unicode2Str="" at="" 0x394d70="">, 253: <function <lambda="">
    at 0x398eb0>, <type 'str'="">: <function Thing2Literal="" at="" 0x3989b0="">, <type 'list'="">: <built-in function="" escape_sequence="">, 248: <function Str2Set="" at="" 0x394530="">, <type 'long'="">: <function Thing2Str="" at="" 0x394cb0="">, <type 'type'="">:
    <function DateTimeDelta2literal="" at="" 0x38feb0="">, <type 'object'="">: <function Instance2Str="" at="" 0x3989f0="">, 254:
    <function <lambda=""> at 0x398eb0>}

    [MacOSX/Python 2.3.4]

     
  • perica
    perica
    2004-06-12

    Logged In: YES
    user_id=1060242

    this is what I have after print:

    conv = {0: <type 'float'="">, 1: <type 'int'="">, 2: <type 'int'="">, 3:
    <type 'long'="">, 4: <type 'float'="">, 5: <type 'float'="">,
    <type 'int'="">: <function Thing2Str="" at="" 0x81be95c="">, 7:
    <function mysql_timestamp_converter="" at="" 0x81be844="">, 8:
    <type 'long'="">, 9: <type 'int'="">, 10: <function Date_or_None="" at="" 0x81be7d4="">, 11: <function Time_or_None="" at="" 0x81be79c="">,
    12: <function DateTime_or_None="" at="" 0x81be72c="">, 13:
    <type 'int'="">, <type 'list'="">: <built-in function="" escape_sequence="">, <type 'type'="">: <function DateTimeDelta2literal="" at="" 0x81be80c="">, <type 'float'="">:
    <function Float2Str="" at="" 0x81d987c="">, <type 'instance'="">:
    <function Instance2Str="" at="" 0x81d9924="">, <type 'array.array'="">:
    <function array2Str="" at="" 0x81d9994="">, <type 'object'="">:
    <function Instance2Str="" at="" 0x81d9924="">, <type 'dict'="">: <built- in="" function="" escape_dict="">, <type 'str'="">: <function Thing2Literal="" at="" 0x81d98ec="">, <type 'NoneType'="">: <function None2NULL="" at="" 0x81d98b4="">, <type 'long'="">: <function Thing2Str="" at="" 0x81be95c="">, <type 'unicode'="">: <function Unicode2Str="" at="" 0x81d964c="">, 248: <function Str2Set="" at="" 0x81be924="">, <type 'tuple'="">: <built-in function="" escape_sequence="">, 252: [(128, <function char_array="" at="" 0x81d995c="">), (None, None)]}

     
  • Andy Dustman
    Andy Dustman
    2004-06-13

    Logged In: YES
    user_id=71372

    conv (in kwargs2) is passed to the
    _mysql.Connection.init() method as a keyword arg.
    There's no way can see
    (_mysql.c:_mysql_ConnectionObject_Initialize() 428-533 in
    1.0.0) for that value to ever be None. If no value of conv
    is passed, it's initialized with a new dictionary; see 471-479.

    Some other things to try:

    1) After printing the value of kwargs2['conv'], print
    self.converter

    2) _mysql.c has this for member access:

    1929 MyMember(
    1930 "converter",
    1931 T_OBJECT,
    1932
    offsetof(_mysql_ConnectionObject,converter),
    1933 0,
    1934 "Type conversion mapping"
    1935 ),

    Change the 0 on 1933 to RO. Rebuild and reinstall.

     
  • beat birkhofer
    beat birkhofer
    2004-06-14

    Logged In: YES
    user_id=302344

    With this modification it works for me. self.converter is of
    type 'dict'.

     
  • perica
    perica
    2004-06-16

    Logged In: YES
    user_id=1060242

    I tried 1) and printed value is "None" I also changed 2) but
    same error again...

     
  • Andy Dustman
    Andy Dustman
    2004-06-17

    Logged In: YES
    user_id=71372

    Beat, which modification fixed it for you?

     
  • beat birkhofer
    beat birkhofer
    2004-06-17

    Logged In: YES
    user_id=302344

    Hi

    Anyway I have to comment out the crypt library in setup.py
    (lines 40 and 41) and then change Line 1933 in _mysql.c.
    That's all (in 1.1.1).

    Beat H.

     
  • perica
    perica
    2004-06-17

    Logged In: YES
    user_id=1060242

    I tried with commenting out lines 40&41 in setup.py and after
    recompile and reinstall still same problem... what am I doing
    wrong?...

     
1 2 > >> (Page 1 of 2)