Python 3 incompatbilities in models.py
See original GitHub issueIssue Description
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 bebytes
in Python 3.model.Query.get_primary_hash_key
usesdb_value
to convert the primary key value into the Redis key suffix. So we end up with keys likeuser.id.b'joedoe'
.model.Model.load()
iterates over the field names, which are (unicode) strings and looks them up inraw_data
, which is a dict withbytes
keys, sinceredis.hgetall()
returns all hash field names asbytes
objects. Consequently all field values of the Model instance will beNone
.
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
Walrus tests are currently passing with Python 3.6, so I think this can be closed out.