bzr grep does not handle binary files cleanly

Bug #531336 reported by Parth Malwankar
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bzr-grep
Fix Released
High
Parth Malwankar

Bug Description

[bingrep]% bzr grep parthm bin.file
bzr: ERROR: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 1: ordinal not in range(128)

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    attaching the crash file
        /home/parthm/.cache/crash/bzr-20100303130926-23727.crash
    and including a description of the problem.

    The crash file is plain text and you can inspect or edit it to remove
    private information.
[bingrep]%

Related branches

Revision history for this message
Parth Malwankar (parthm) wrote :
Changed in bzr-grep:
status: New → In Progress
importance: Undecided → Medium
importance: Medium → High
assignee: nobody → Parth Malwankar (parthm)
Revision history for this message
Parth Malwankar (parthm) wrote :

[bingrep]% bzr grep foo bin.file
Binary file 'bin.file' skipped.
[bingrep]%

Changed in bzr-grep:
status: In Progress → Fix Released
Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 531336] Re: bzr grep does not handle binary files cleanly

On 4 March 2010 01:12, Parth Malwankar <email address hidden> wrote:
> [bingrep]% bzr grep foo bin.file
> Binary file 'bin.file' skipped.
> [bingrep]%

That's good if it really is binary. Can it also cope with non-ascii text files?

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Parth Malwankar (parthm) wrote :

On Mon, Mar 8, 2010 at 1:58 PM, Martin Pool <email address hidden> wrote:
> On 4 March 2010 01:12, Parth Malwankar <email address hidden> wrote:
>> [bingrep]% bzr grep foo bin.file
>> Binary file 'bin.file' skipped.
>> [bingrep]%
>
> That's good if it really is binary.  Can it also cope with non-ascii
> text files?
>
>
> --
> Martin <http://launchpad.net/~mbp/>
>

I am not really a unicode expert so a review would be good. I have already
raised a request for review[1]. For handling this case I am using
bzrlib.textfile.text_file.

    # test and skip binary files
    str_file = cStringIO.StringIO(tree.get_file_text(id))
    try:
        iter_file = textfile.text_file(str_file)
    except errors.BinaryFile, e:
        trace.warning("Binary file '%s' skipped." % path)
        return

    index = 1
    for line in iter_file:
......

[1] https://code.launchpad.net/~parthm/bzr-grep/bzr-grep-1st-full-review/+merge/20634

Revision history for this message
Martin Pool (mbp) wrote :

that's pretty good

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.