desc_path = os.path.join(path, 'profiles', 'profiles.desc')
try:
- desc_file = codecs.open(desc_path, mode='r', errors='replace')
+ desc_file = codecs.open(desc_path, mode='r',
+ encoding='utf_8', errors='replace')
except EnvironmentError:
pass
else:
continue
try:
line = 1
- for l in codecs.open(checkdir+"/"+y, "r", "utf8"):
+ for l in codecs.open(os.path.join(checkdir, y), mode='r',
+ encoding='utf_8'):
line +=1
except UnicodeDecodeError, ue:
stats["file.UTF8"] += 1
repo_conf_parser = SafeConfigParser()
try:
repo_conf_parser.readfp(
- codecs.open(self._local_repo_conf_path,
- mode='r', errors='replace'))
+ codecs.open(self._local_repo_conf_path, mode='r',
+ encoding='utf_8', errors='replace'))
except EnvironmentError, e:
if e.errno != errno.ENOENT:
raise
# once, which may be expensive due to digging in child classes.
func = self.lineParser
for fn in RecursiveFileLoader(self.fname):
- f = codecs.open(fn, mode='r', errors='replace')
+ f = codecs.open(fn, mode='r', encoding='utf_8', errors='replace')
for line_num, line in enumerate(f):
func(line, line_num, data, errors)
return (data, errors)
return token
try:
lineno=0
- for line in codecs.open( myfile, mode = 'r', errors = 'replace' ):
+ for line in codecs.open( myfile, mode='r',
+ encoding='utf_8', errors='replace' ):
lineno += 1
commenter_pos = line.find("#")
else:
try:
myfile = codecs.open(myfilename, mode='r',
- encoding=sys.getdefaultencoding(), errors='replace')
+ encoding='utf_8', errors='replace')
mylines = myfile.readlines()
myfile.close()
except IOError, e:
# Workaround for avoiding a silent error in shlex that
# is triggered by a source statement at the end of the file without a
# trailing newline after the source statement
- content = codecs.open(mycfg, mode='r', errors='replace').read()
- if content and content[-1] != u'\n':
- content += u'\n'
- f = StringIO(content)
+ # NOTE: shex doesn't seem to supported unicode objects
+ # (produces spurious \0 characters with python-2.6.2)
+ content = open(mycfg).read()
+ if content and content[-1] != '\n':
+ content += '\n'
except IOError, e:
if e.errno == PermissionDenied.errno:
raise PermissionDenied(mycfg)
# The default shlex.sourcehook() implementation
# only joins relative paths when the infile
# attribute is properly set.
- lex = shlex_class(f, infile=mycfg, posix=True)
+ lex = shlex_class(content, infile=mycfg, posix=True)
lex.wordchars = string.digits + string.ascii_letters + \
"~!@#$%*_\:;?,./-+{}"
lex.quotes="\"'"
open_func = open
else:
open_func = codecs.open
+ kargs.setdefault('encoding', 'utf_8')
kargs.setdefault('errors', 'replace')
if follow_links: