2

I was taking a look to a couple of related questions which treats about the same issue, but I still don't find a way to solve it.

It turns out that every time I execute a Django-related command, it prints me out the expected output plus something like this:

/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py:307: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return name == ":memory:" or "mode=memory" in force_text(name)

And here is the context of that line:

def is_in_memory_db(self, name):
    return name == ":memory:" or "mode=memory" in force_text(name)

Despite the Django server works, it's kind of annoying having always this message printed out on my screen. So, why is this happening and how could this be solved?

Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82
Franzech Domâs
  • 249
  • 2
  • 7
  • Possible duplicate of [Python unicode equal comparison failed](https://stackoverflow.com/questions/18193305/python-unicode-equal-comparison-failed) – Alastair Irvine Jul 26 '17 at 10:13

1 Answers1

3

use decode('utf-8') to make correct comparing:

name.decode('utf-8') == ":memory:" or "mode=memory" in force_text(name)

Use full info:

Unicode HOWTO

Solving Unicode Problems in Python 2.7

Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82