#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 "", 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: , 1: , 2: , 3: , : , 5: , 7: , 8: , 9:
    , 10: , 11:
    , 12: , 13: , : , 252: [(128,
    ), (None, at 0x398eb0>), (None, None)]
    , :
    , 4: , : , : , : , : , :
    , 253:
    at 0x398eb0>, : , : , 248: , : , :
    , : , 254:
    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: , 1: , 2: , 3:
    , 4: , 5: ,
    : , 7:
    , 8:
    , 9: , 10: , 11: ,
    12: , 13:
    , : , : , :
    , :
    , :
    , :
    , : , : , : , : , : , 248: , : , 252: [(128, ), (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)