TypeError: coercing to Unicode: need string or buffer, instance found

Discussion in 'Python' started by Stuart Forsyth, Nov 13, 2003.

  1. What can I do about this error, i am tearing my hair out!

    Python ActiveX Scripting Engine (0x80020009)
    Traceback (most recent call last): File "<Script Block >", line 58, in ?
    FileContents =
    FileContents.replace('Repl_learner',unicode(Request("learner"),'utf-8','igno
    re')) TypeError: coercing to Unicode: need string or buffer, instance found

    FileContents is defined as:

    MasterFile = codecs.open(MasterFilePath, "r", "utf-8")
    FileContents = MasterFile.read()

    Please help !
     
    Stuart Forsyth, Nov 13, 2003
    #1
    1. Advertising

  2. "Stuart Forsyth" <> schrieb im Newsbeitrag
    news:D...
    | What can I do about this error, i am tearing my hair out!
    |
    | Python ActiveX Scripting Engine (0x80020009)
    | Traceback (most recent call last): File "<Script Block >", line 58, in ?
    | FileContents =
    |
    FileContents.replace('Repl_learner',unicode(Request("learner"),'utf-8','igno
    | re')) TypeError: coercing to Unicode: need string or buffer, instance
    found
    |
    | FileContents is defined as:
    |
    | MasterFile = codecs.open(MasterFilePath, "r", "utf-8")
    | FileContents = MasterFile.read()
    |
    | Please help !
    |

    You should inspect 'Request("learner")' more closely. It propbably doesn't
    return an encoded string, but an instance of some sort...
    I'm not really on board with ActiveX, but shouldn't you call some sort of a
    method on Request to get a collection (e.g. Request.Form("learner")?

    Regards,
    Vincent Wehren
     
    vincent wehren, Nov 13, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Randall Parker
    Replies:
    2
    Views:
    834
    Fredrik Lundh
    Mar 22, 2006
  2. Max Erickson
    Replies:
    0
    Views:
    1,290
    Max Erickson
    Jun 21, 2006
  3. Fredrik Lundh
    Replies:
    0
    Views:
    779
    Fredrik Lundh
    Jun 21, 2006
  4. Jon Bowlas
    Replies:
    6
    Views:
    20,204
    Jon Bowlas
    Jul 27, 2006
  5. special_dragonfly

    SQLite and coercing to Unicode - please help.

    special_dragonfly, Sep 6, 2007, in forum: Python
    Replies:
    3
    Views:
    363
    Steve Holden
    Sep 6, 2007
Loading...

Share This Page