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
1=== modified file 'src/lazr/restful/_resource.py'
2--- src/lazr/restful/_resource.py 2020-09-24 10:01:25 +0000
3+++ src/lazr/restful/_resource.py 2021-01-21 00:06:16 +0000
4@@ -1117,9 +1117,13 @@
5
6 if IBytes.providedBy(field):
7 # We don't modify Bytes fields from the Entry that contains
8- # them, but we may tell users how to do so if they attempt to
9- # change them.
10- if value != current_value:
11+ # them, but we may tell users how to do so if they attempt
12+ # to change them. The encode call is because
13+ # BytesFieldMarshaller.unmarshall returns a link to the byte
14+ # storage resource as a str, but
15+ # BytesFieldMarshaller.marshall_from_json_data returns
16+ # bytes.
17+ if value != current_value.encode('UTF-8'):
18 if field.readonly:
19 errors.append(modified_read_only_attribute
20 % repr_name)

Subscribers

People subscribed via source and target branches