Merge lp:~cjwatson/lazr.restful/py3-fix-bytes-modification-detection into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 284
Proposed branch: lp:~cjwatson/lazr.restful/py3-fix-bytes-modification-detection
Merge into: lp:lazr.restful
Diff against target: 20 lines (+7/-3)
1 file modified
src/lazr/restful/_resource.py (+7/-3)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-fix-bytes-modification-detection
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+396622@code.launchpad.net

Commit message

Fix detection of Bytes field modifications on Python 3.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lazr/restful/_resource.py'
--- src/lazr/restful/_resource.py 2020-09-24 10:01:25 +0000
+++ src/lazr/restful/_resource.py 2021-01-21 00:06:16 +0000
@@ -1117,9 +1117,13 @@
11171117
1118 if IBytes.providedBy(field):1118 if IBytes.providedBy(field):
1119 # We don't modify Bytes fields from the Entry that contains1119 # We don't modify Bytes fields from the Entry that contains
1120 # them, but we may tell users how to do so if they attempt to1120 # them, but we may tell users how to do so if they attempt
1121 # change them.1121 # to change them. The encode call is because
1122 if value != current_value:1122 # BytesFieldMarshaller.unmarshall returns a link to the byte
1123 # storage resource as a str, but
1124 # BytesFieldMarshaller.marshall_from_json_data returns
1125 # bytes.
1126 if value != current_value.encode('UTF-8'):
1123 if field.readonly:1127 if field.readonly:
1124 errors.append(modified_read_only_attribute1128 errors.append(modified_read_only_attribute
1125 % repr_name)1129 % repr_name)

Subscribers

People subscribed via source and target branches