Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3393108
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:00:42+00:00 2026-05-18T04:00:42+00:00

Below is the full log, the problem is in 23 dd.append(str(msg.get_json())) I have some

  • 0

Below is the full log, the problem is in

   23             dd.append(str(msg.get_json()))

I have some utf-8 returned from msg.get_json()…
Will str() try to encode the parameter using ASCII?

<type 'exceptions.UnicodeEncodeError'>  Python 2.6.5: /usr/bin/python
Mon Nov 15 18:53:39 2010

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
 /usr/lib/pymodules/python2.6/flup/server/fcgi_base.py in run(self=<flup.server.fcgi_base.Request object>)
  556         """Runs the handler, flushes the streams, and ends the request."""
  557         try:
  558             protocolStatus, appStatus = self.server.handler(self)
  559         except:
  560             traceback.print_exc(file=self.stderr)
protocolStatus undefined, appStatus undefined, self = <flup.server.fcgi_base.Request object>, self.server = <flup.server.fcgi.WSGIServer object>, self.server.handler = <bound method WSGIServer.handler of <flup.server.fcgi.WSGIServer object>>
 /usr/lib/pymodules/python2.6/flup/server/fcgi_base.py in handler(self=<flup.server.fcgi.WSGIServer object>, req=<flup.server.fcgi_base.Request object>)
 1116         try:
 1117             try:
 1118                 result = self.application(environ, start_response)
 1119                 try:
 1120                     for data in result:
result = None, self = <flup.server.fcgi.WSGIServer object>, self.application = <function app>, environ = {'CONTENT_LENGTH': '81', 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8', 'DOCUMENT_ROOT': '/usr/local/nginx/html', 'DOCUMENT_URI': '/a.bc', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/json, text/javascript, */*', 'HTTP_ACCEPT_CHARSET': 'GB2312,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'zh-cn,zh;q=0.5', 'HTTP_CACHE_CONTROL': 'no-cache', ...}, start_response = <function start_response>
 /root/bc/trunk/python/server.py in app(environ={'CONTENT_LENGTH': '81', 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8', 'DOCUMENT_ROOT': '/usr/local/nginx/html', 'DOCUMENT_URI': '/a.bc', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/json, text/javascript, */*', 'HTTP_ACCEPT_CHARSET': 'GB2312,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'zh-cn,zh;q=0.5', 'HTTP_CACHE_CONTROL': 'no-cache', ...}, start_response=<function start_response>)
  125     config.dbg(cmd_name)
  126     if cmd_name in cmd_map:
  127         ret = cmd_map[cmd_name](q)
  128     else:
  129         ret = '{"' + cmd_name + '": {"result":"error"}}';
ret = 'cmd=get_room_updates&room=room2&connectionid=90125080-f0a6-11df-9dcb-0800279f1ca2', global cmd_map = {'chat_message': <function chat_message_cmd>, 'enter_room': <function enter_room_cmd>, 'get_room_updates': <function get_room_updates_cmd>, 'login_user': <function login_user_cmd>, 'register_user': <function register_user_cmd>}, cmd_name = 'get_room_updates', q = {'cmd': ['get_room_updates'], 'connectionid': ['90125080-f0a6-11df-9dcb-0800279f1ca2'], 'room': ['room2']}
 /root/bc/trunk/python/server.py in get_room_updates_cmd(qs={'cmd': ['get_room_updates'], 'connectionid': ['90125080-f0a6-11df-9dcb-0800279f1ca2'], 'room': ['room2']})
   88         room = config.gOnlineRooms[room_name]
   89         conn = room.chat_connections[connectionid]
   90         remaining = conn.get_pending_message()
   91 
   92     return remaining 
remaining = '[]', conn = <ChatConnection.ChatConnection instance>, conn.get_pending_message = <bound method ChatConnection.get_pending_message of <ChatConnection.ChatConnection instance>>
 /root/bc/trunk/python/ChatConnection.py in get_pending_message(self=<ChatConnection.ChatConnection instance>)
   21         for msg in self.pending_message:
   22             txt = txt + msg.get_json() + ","
   23             dd.append(str(msg.get_json()))
   24 
   25         config.dbg("dd = " + str(dd))
dd = [], dd.append = <built-in method append of list object>, builtin str = <type 'str'>, msg = <Message.Message instance>, msg.get_json = <bound method Message.get_json of <Message.Message instance>>

<type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 79-80: ordinal not in range(128)
      args = ('ascii', u'{"id":"168", "username":"binc2", "ctime":"2010-11-15 18:53:37.165260", "body":"\u4e2d\u56fd", "room":"room2"}', 79, 81, 'ordinal not in range(128)')
      encoding = 'ascii'
      end = 81
      message = ''
      object = u'{"id":"168", "username":"binc2", "ctime":"2010-11-15 18:53:37.165260", "body":"\u4e2d\u56fd", "room":"room2"}'
      reason = 'ordinal not in range(128)'
      start = 79 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:00:42+00:00Added an answer on May 18, 2026 at 4:00 am

    The problem is most likely ocurring in str(msg.get_json()) or one of the other places where you use str. The object contains unicode data and str is not built to handle unicode. You should be able to use json.dumps(msg.get_json()) instead. Alternatively use str(msg.get_json().decode('utf-8')).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.