Conversation
…emoved silently post Django 1.11
There was a problem hiding this comment.
✨ PR Review
The PR introduces Django 2.1 compatibility changes and black formatting. However, there are two critical bugs that will cause runtime failures: Python 3 incompatible base64 decoding and incorrect Django reverse() API usage.
2 issues detected:
🐞 Bug - Using string.decode("base64") which doesn't exist in Python 3 🛠️
Details: The base64 decoding method is incompatible with Python 3. In Python 3, strings don't have a decode() method. This will cause an AttributeError at runtime when HTTP Basic Authentication is used.
File:piston/authentication.py (60-60)
🛠️ A suggested code correction is included in the review comments.🐞 Bug - Passing fields as the second positional argument (urlconf) instead of as args or kwargs keyword argument 🛠️
Details: The reverse() function is being called with incorrect arguments. The second argument to reverse() is 'urlconf', not 'args'. The old code used permalink() which properly handled the args/kwargs distinction, but this direct call will fail or produce incorrect URLs.
File:piston/emitters.py (287-287)
🛠️ A suggested code correction is included in the review comments.
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how
|
|
||
| auth = auth.strip().decode('base64') | ||
| (username, password) = auth.split(':', 1) | ||
| auth = auth.strip().decode("base64") |
There was a problem hiding this comment.
🐞 Bug - Python 3 Incompatible: Replace with: auth = base64.b64decode(auth.strip()).decode('utf-8') and add import base64 at the top of the file.
| auth = auth.strip().decode("base64") | |
| auth = base64.b64decode(auth.strip()).decode('utf-8') |
Is this review accurate? Use 👍 or 👎 to rate it
If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over
|
|
||
| try: | ||
| ret['resource_uri'] = reverser(lambda: (url_id, fields))() | ||
| ret["resource_uri"] = reverse(url_id, fields) |
There was a problem hiding this comment.
🐞 Bug - Incorrect API Usage: Replace with: ret["resource_uri"] = reverse(url_id, args=fields) if fields is a tuple/list, or ret["resource_uri"] = reverse(url_id, kwargs=fields) if fields is a dict. Check what resource_uri() returns to determine the correct parameter name.
| ret["resource_uri"] = reverse(url_id, fields) | |
| ret["resource_uri"] = reverse(url_id, args=fields) |
Is this review accurate? Use 👍 or 👎 to rate it
If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over
|
wow, blast from the past ;p |


✨ PR Description
Purpose: Update Django Piston codebase to support Django 2.1 by migrating deprecated import paths and applying black code formatter for consistent style.
Main changes:
django.core.urlresolverstodjango.urlsmodule for Django 2.1 compatibilityon_delete=models.CASCADEparameter per Django 2.1 requirementsGenerated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how