question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python 3 incompatbilities in models.py

See original GitHub issue

model.py uses basestring and unicode, which are gone in Python 3.

Also, there are a few issues stemming form the unicode-ness of strings in Python 3:

  • model.TextField.db_value() converts to encoded strings, which would be bytes in Python 3. model.Query.get_primary_hash_key uses db_value to convert the primary key value into the Redis key suffix. So we end up with keys like user.id.b'joedoe'.
  • model.Model.load() iterates over the field names, which are (unicode) strings and looks them up in raw_data, which is a dict with bytes keys, since redis.hgetall() returns all hash field names as bytes objects. Consequently all field values of the Model instance will be None.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
coleifercommented, May 9, 2017

@SpotlightKid, usually I try to be very nice as a maintainer, but don’t bitch about my library in one comment then tell me how to design it in another.

0reactions
coleifercommented, May 23, 2018

Walrus tests are currently passing with Python 3.6, so I think this can be closed out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Porting to Python 3 | Django documentation
Writing compatible code is much easier if you target Python ≥ 2.6. Django 1.5 introduces compatibility tools such as django.utils.six , which is...
Read more >
Python 3 incompatibilities · Issue #1074 · DefectDojo/django ...
Python 3 incompatibilities #1074 ... dojo/models.py:1459:16: F821 undefined name 'unicode' return unicode(base64.b64decode(self.
Read more >
How to write code that works in both Python 2 and Python 3?
The original recommended answer was to use 2to3, a tool that can automatically convert Python 2 code to Python 3 code, or guide...
Read more >
Porting Python 2 Code to Python 3 — Python 3.11.1 ...
Update your setup.py file to denote Python 3 compatibility¶. Once your code works under Python 3, you should update the classifiers in your...
Read more >
3. Data model — Python 3.11.1 documentation
Objects, values and types: Objects are Python's abstraction for data. All data in a Python program is represented by objects or by relations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found