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 7059483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:14:15+00:00 2026-05-28T04:14:15+00:00

I get a strange error message when trying to read non-ascii from the datastore:

  • 0

I get a strange error message when trying to read non-ascii from the datastore:

'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
Traceback (most recent call last):
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/handler.py", line 127, in dispatch
    response = super(NewBaseHandler, self).dispatch()
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/handler.py", line 73, in check_login
    return handler(self, *args, **kwargs)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/handler.py", line 526, in get
    user=user)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/handler.py", line 91, in render_jinja
    **template_args))
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2_extras/jinja2.py", line 158, in render_template
    return self.environment.get_template(_filename).render(**context)
  File "/base/data/home/apps/s~myapp-www/events.355951895377615944/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "template_files/my_organization.html", line 148, in top-level template code
    <li id="{{ person.key.id()|makeid }}" class="level_1 inactive   leaf"><a href="" style="" class=""><ins>&nbsp;</ins><table class="leaf_info"><tbody>    <tr><td class="name">{{ person.firstname }} {{ person.lastname}} {{person.key.id()|makeid}}</td><td class="level" title="New Distributor"><span class="level_parseable">1</span>1</td><td class="downlines">0</td><td class="cc_personal"><span class="cc_personal_parseable"></span>0</td><td class="cc_downlines"><span class="cc_downlines_parseable"></span>0</td><td class="cc_activity"><span class="cc_activity_parseable"></span>0</td><td class="cc_nonmanager"><span class="cc_nonmanager_parseable"></span>0</td><td class="cc_total"><span class="cc_total_parseable"></span>0</td></tr></tbody></table></a></li>{% endfor %}
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)

The loop that used to work is ordinary:

{% for person in people %}
    <li id="{{ person.key.id()|makeid }}" class="level_1 inactive   leaf">
<a href="" style="" class=""><ins>&nbsp;</ins><table class="leaf_info"><tbody>  <tr><td class="name">{{ person.firstname }} {{ person.lastname}} {{person.key.id()|makeid}}</td><td class="level" title="New Distributor"><span class="level_parseable">1</span>1</td><td class="downlines">0</td><td class="cc_personal"><span class="cc_personal_parseable"></span>0</td><td class="cc_downlines"><span class="cc_downlines_parseable"></span>0</td><td class="cc_activity"><span class="cc_activity_parseable"></span>0</td><td class="cc_nonmanager"><span class="cc_nonmanager_parseable"></span>0</td><td class="cc_total"><span class="cc_total_parseable"></span>0</td></tr></tbody></table></a></li>
{% endfor %}

What can I do to resolve this error?

My handler looks like this

class Myorg(NewBaseHandler):
    @user_required
    def get(self):
        user = auth_models.User.get_by_id(long(self.auth.get_user_by_session()['user_id']))
        people = auth_models.User.query(auth_models.User.sponsor == user.key).fetch()
        self.render_jinja('my_organization.html', people=people,
                              user=user)

And my model definition is the User model from webapp2. Here is also my custom filer makeid:

def makeid(n, countrycode="46"):
    countrycode = str(countrycode)
    n = str(n)
    return "%s%s%s" % (countrycode, '0'*(12-len(countrycode)-len(n)), n)

Update

The workaround is strange, I just make a .decode('utf-8') which is shouldn’t need to be doing:

class UpdateHandler(NewBaseHandler):

    @user_required
    def get(self):
        user = \
            auth_models.User.get_by_id(long(self.auth.get_user_by_session()['user_id'
                ]))
        sponsor = None
        if user.sponsor:
            sponsor = user.sponsor.get()
        address = None
        if user.address:
            address = user.address.decode('utf-8')
        if user.city:
            city = user.city.decode('utf-8')
        self.render_jinja('details.html', city=city, user=user, address=address, sponsor=sponsor, form=UpdateForm(obj=user))

Is there any way to decode the all of the variables of the user object at once instead of one by one?

  • 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-28T04:14:16+00:00Added an answer on May 28, 2026 at 4:14 am

    You’re attempting to interpolate a raw (byte) string into a Unicode template. This is done by attempting to decode the raw string into unicode using some encoding – here, the default ‘ascii’ encoding – which is failing because it’s encountering a codepoint that isn’t valid for ASCII.

    To fix this, you need to pass only unicode strings into your template – decode the string using the correct codec before passing it in.

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

Sidebar

Related Questions

Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc
I have a strange issue. I'm trying to get Apple Push Notifications working with
Here's the message I get when trying to install in via cabal-install: $ cabal
When trying to compile a project with TeamCity, I am getting an error from
Im facing a strange issue trying to move from sql server to oracle. in
I'm getting something pretty strange going on when trying to read some data using
I have very strange error I can't understand. I started a new project throw
I am trying to get the second value from a CSV file with 100
I'm getting a very strange error message when I try to iterate through an
I am experiencing a very strange error (could be a bug). I am trying

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.