--
To reply, visit https://hellosplat.com/s/beanbag/tickets/4736/
--
New ticket #4736 by basil
For Beanbag, Inc. > RBTools
Status: New
Tags: Priority:Medium, Type:Defect
--
rbt patch --print does not work on Python 3
==
# What version are you running?
```
$ rbt --version
RBTools 1.0.1
$ python2 --version
Python 2.7.10
$ python3 --version
Python 3.6.6
```
# What steps will reproduce the problem?
1. Create a virtual environment and install RBTools.
2. Run `rbt patch --print `.
# What is the expected output? What do you see instead?
The expected output is a readable patch, and I get the expected output when the
virtual environment in step 1 is created with Python 2:
```
diff --git a/path/to/file1 b/path/to/file1
index
d27838edc524e3813ae1019d534067e9a8bceb4c..264a986b38050f935b2f2df40875e76087fbad0e
100644
--- a/path/to/file1
+++ b/path/to/file1
@@ -41,6 +41,7 @@
[...]
```
However, when the virtual environment in step 1 is created with Python 3, I see
the following instead:
```
b'diff --git a/path/to/file1 b/path/to/file1\nindex
d27838edc524e3813ae1019d534067e9a8bceb4c..264a986b38050f935b2f2df40875e76087fbad0e
100644\n--- a/path/to/file1\n+++ b/path/to/file1\n@@ -41,6 +41,7 @@
[...]
```
# What operating system are you using?
macOS High Sierra 10.13.6
# Attach the debug out from the command.
```
$ rbt patch --debug --print
>>> RBTools 1.0.1
>>> Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
>>> Running on Darwin-17.7.0-x86_64-i386-64bit
>>> Home = /Users/basil
>>> Current directory = /Users/basil/path/to/repository
>>> Command line: rbt patch --debug --print 42917
>>> Making HTTP GET request to http://reviews.example.com/api/
>>> Making HTTP GET request to
>>> http://reviews.example.com/api/review-requests/42917/diffs/
>>> Cached response for HTTP GET
>>> http://reviews.example.com/api/review-requests/42917/diffs/ expired and was
>>> modified
>>> Making HTTP GET request to
>>> http://reviews.example.com/api/review-requests/42917/diffs/1/
>>> Cached response for HTTP GET
>>> http://reviews.example.com/api/review-requests/42917/diffs/1/ expired and
>>> was not modified
>>> Making HTTP GET request to
>>> http://reviews.example.com/api/review-requests/42917/diffs/1/
>>> Cached response for HTTP GET
>>> http://reviews.example.com/api/review-requests/42917/diffs/1/ expired and
>>> was not modified
b'diff --git a/path/to/file1 b/path/to/file1\nindex
d27838edc524e3813ae1019d534067e9a8bceb4c..264a986b38050f935b2f2df40875e76087fbad0e
100644\n--- a/path/to/file1\n+++ b/path/to/file1\n@@ -41,6 +41,7 @@
[...]
```
# Please provide any additional information below.
This change to RBTools works around the problem successfully on both Python 2
and Python 3:
```
diff --git a/rbtools/commands/patch.py b/rbtools/commands/patch.py
index 1ea5665..70c7a20 100644
--- a/rbtools/commands/patch.py
+++ b/rbtools/commands/patch.py
@@ -82,6 +82,9 @@ class Patch(Command):
try:
diff = diffs.get_item(diff_revision)
diff_body = diff.get_patch().data
+diff_body = (
+diff_body.decode('utf-8') if isinstance(diff_body, bytes) else
diff_body
+)
base_dir = getattr(diff, 'basedir', None) or ''
except APIError:
raise CommandError('The specified diff revision does not exist.')
```
--
--
You received this message because you are subscribed to the Google Groups
"reviewboard-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to reviewboard-issues+unsubscr...@googlegroups.com.
To post to this group, send email to reviewboard-issues@googlegroups.com.
Visit this group at https://groups.google.com/group/reviewboard-issues.
For more options, visit https://groups.google.com/d/optout.