4969: interdiff sometimes fails with a variable used before assignment
- Fixed
- Review Board
grim | |
chipx86 |
What version are you running?
4.0.6
What's the URL of the page containing the problem?
https://reviews.imfreedom.org/r/1293/diff/3-4/
What steps will reproduce the problem?
Not sure actually, but the interdiff was created via
hg rebase
and the diff is attached.What is the expected output? What do you see instead?
The diff instead of a python error :-D
What operating system are you using? What browser?
Linux, Chrome/Firefox
Please provide any additional information below.
We've seen this across a number of review requests, it's not a huge deal as it's interdiffs, but would be great it if was working properly.
Also since this was from a rebase, I've provided a diff with just the files failing in the interdiff as well as the entire diff between the final revision and the one that was obsoleted.
The error:
Traceback (most recent call last): File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/views.py", line 447, in get response = renderer.render_to_response(request) File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 57, in render_to_response return HttpResponse(self.render_to_string(request)) File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 72, in render_to_string return cache_memoize( File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 312, in cache_memoize results = list(cache_memoize_iter(key, File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 254, in cache_memoize_iter items = items_or_callable() File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 313, in <lambda> lambda: [lookup_callable()], File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 74, in <lambda> lambda: self.render_to_string_uncached(request), File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/renderers.py", line 87, in render_to_string_uncached populate_diff_chunks([self.diff_file], self.highlighting, File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/diffutils.py", line 1251, in populate_diff_chunks chunks = list(generator.get_chunks()) File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 996, in get_chunks for chunk in super(DiffChunkGenerator, self).get_chunks(cache_key): File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 161, in get_chunks chunks = cache_memoize(cache_key, File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 312, in cache_memoize results = list(cache_memoize_iter(key, File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 254, in cache_memoize_iter items = items_or_callable() File "/venv/lib/python3.8/site-packages/djblets/cache/backend.py", line 313, in <lambda> lambda: [lookup_callable()], File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 162, in <lambda> lambda: list(self.get_chunks_uncached()), File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 1119, in get_chunks_uncached for chunk in self.generate_chunks(old=old, File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 305, in generate_chunks lines = [ File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 306, in <listcomp> self._diff_line(tag, meta, *diff_args) File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 533, in _diff_line old_markup, new_markup = self._highlight_indentation( File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 600, in _highlight_indentation new_markup = self._wrap_indentation_chars( File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 646, in _wrap_indentation_chars serialized, remainder = serializer(indentation, norm_indent_len_diff) File "/venv/lib/python3.8/site-packages/reviewboard/diffviewer/chunk_generator.py", line 688, in _serialize_indentation return s, chars[j + 1:] UnboundLocalError: local variable 'j' referenced before assignment
I looked into this a bit when you reported this to me, and... the cause of that
UnboundLocalError
is easily fixed, but it shouldn't be hitting that code to begin with unless it'd be in a state wherej
would be assigned. So there's a real bug with that function, but also something leading to that function being called. Kinda weird. Going to require some investigation.
Fix up for review: https://reviews.reviewboard.org/r/12362/
-
- New + PendingReview -
+ Release-4.0.x -
+ Component:DiffViewer -
+ chipx86