/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/ignores.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import errno
22
22
import os
23
 
from cStringIO import StringIO
24
23
 
25
24
import breezy
26
 
from breezy.lazy_import import lazy_import
 
25
from .lazy_import import lazy_import
27
26
lazy_import(globals(), """
28
27
from breezy import (
29
28
    atomicfile,
32
31
    trace,
33
32
    )
34
33
""")
 
34
from breezy.sixish import (
 
35
    BytesIO,
 
36
    )
35
37
 
36
38
# ~/.bazaar/ignore will be filled out using
37
39
# this ignore list, if it does not exist
92
94
    patterns = set(USER_DEFAULTS)
93
95
    try:
94
96
        f = open(path, 'rb')
95
 
    except (IOError, OSError), e:
 
97
    except (IOError, OSError) as e:
96
98
        # open() shouldn't return an IOError without errno, but just in case
97
99
        err = getattr(e, 'errno', None)
98
100
        if err not in (errno.ENOENT,):
102
104
        # since get_* should be a safe operation
103
105
        try:
104
106
            _set_user_ignores(USER_DEFAULTS)
105
 
        except (IOError, OSError), e:
 
107
        except (IOError, OSError) as e:
106
108
            if e.errno not in (errno.EPERM,):
107
109
                raise
108
110
        return patterns
201
203
            file_contents = f.read()
202
204
            # figure out what kind of line endings are used
203
205
            newline = getattr(f, 'newlines', None)
204
 
            if type(newline) is tuple:
 
206
            if isinstance(newline, tuple):
205
207
                newline = newline[0]
206
208
            elif newline is None:
207
209
                newline = os.linesep
211
213
        file_contents = ""
212
214
        newline = os.linesep
213
215
    
214
 
    sio = StringIO(file_contents)
 
216
    sio = BytesIO(file_contents)
215
217
    try:
216
218
        ignores = parse_ignore_file(sio)
217
219
    finally: