Forums

TypeError at / decoding to str: need a bytes-like object, NoneType found

In my web application all function work correctly locally, but in pythonanywhere I get an error:

Exception Value:    
decoding to str: need a bytes-like object, NoneType found
if article.casefold() == entry.casefold():
                    page = util.get_entry(article)
                    page_mark = Markdown().convert(page)

It seems to become a case sensitive in Search field. Lowercase give an error. Any help would be appreciated!

[edit by admin: formatting]

Which of those lines is generating the error?

page_mark = Markdown().convert(page) this line of code is generating above mentioned error.

Have you checked what value page has when you're passing it in to the convert method?

yes I checked. It's a page of entries folder, for example CSS.md. My site work without error on
server at http://127.0.0.1.800

Have you actually checked, or are you just assuming that based on what you expect? Print out the value of page just before you pass it to convert. Prints to stderr in your web app will appear in your error log.

I printed out the value of a page in error log. It prints what I puts into search field. Site became case-sensitive and I don't know how to get rid of it.

 if article.lower() == entry.lower():
                page = util.get_entry(article)
                print(article ,file=sys.stderr)
                page_mark = Markdown().convert(page)

You're passing page into the convert function, so my guess would be that is the issue. Have you checked that?