Uploaded image for project: 'Hue (READ ONLY)'
  1. Hue (READ ONLY)
  2. HUE-9754

filebrowser xxd for binary files fails using Python 3

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Incomplete
    • Affects Version/s: 4.7.0, 4.8.0
    • Fix Version/s: None
    • Component/s: app.filebrowser
    • Labels:
      None

      Description

      When trying to view a binary .gz or avro file in the File Browser when Hue is run using Python 3.7, it is now frequently failing with the below stack trace.

      I tried decoding the value of "contents" in def mask_not_printable(), but this just causes other downstream errors, namely in def xxd() where "line_ordinals" is mapped.  Both errors seem like Python2 to Python3 conversion problems given the differences in how Python 3 handles bytes objects, but I couldn't figure it out.  Commenting out the xxd calls in filebrowser/views.py works around the user seeing 500 errors, but they they are only able to view the binary files as text.

      Traceback (most recent call last):
        File "build/env/lib/python3.7/site-packages/django/core/handlers/exception.py", line 41, in inner
          response = get_response(request)
        File "build/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
          response = self._get_response(request)
        File "build/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
          response = self.process_exception_by_middleware(e, request)
        File "build/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
          response = wrapped_callback(request, *callback_args, **callback_kwargs)
        File "lib/python3.7/contextlib.py", line 74, in inner
          return func(*args, **kwds)
        File "apps/filebrowser/src/filebrowser/views.py", line 217, in view
          return display(request, path)
        File "apps/filebrowser/src/filebrowser/views.py", line 704, in display
          xxd_out = list(xxd.xxd(offset, contents, BYTES_PER_LINE, BYTES_PER_SENTENCE))
        File "apps/filebrowser/src/filebrowser/lib/xxd.py", line 69, in xxd
          line_printable = mask_not_alphanumeric(line)[1]
        File "apps/filebrowser/src/filebrowser/lib/xxd.py", line 51, in mask_not_alphanumeric
          return mask_not_printable(data, NON_FANCY_PRINTABLE)
        File "apps/filebrowser/src/filebrowser/lib/xxd.py", line 44, in mask_not_printable
          out, cnt = mask_re.subn('.', contents)
      TypeError: cannot use a string pattern on a bytes-like object
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rickbernotas Rick Bernotas
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: