Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix UTF-8 handling #76

Open
wants to merge 4 commits into
base: oi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def set_content(self, content=None, excludes=EmptyI, pathname=None,
# together has to be solved somewhere else, though.)
if pathname:
try:
with open(pathname, "r") as mfile:
with open(pathname, "r", encoding='UTF-8') as mfile:
content = mfile.read()
except EnvironmentError as e:
raise apx._convert_error(e)
Expand Down
5 changes: 0 additions & 5 deletions src/modules/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,6 @@ def setlocale(category, loc=None, printer=None):
printer("Unable to set locale{0}; locale package may be broken "
"or\nnot installed. Reverting to C locale.".format(dl))
locale.setlocale(category, "C")
# Correct preferred encoding so that we don't try to decode files with ascii codec
if locale.getpreferredencoding(False) != "UTF-8":
locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")
locale.setlocale(locale.LC_COLLATE, "en_US.UTF-8")

def N_(message):
"""Return its argument; used to mark strings for localization when
their use is delayed by the program."""
Expand Down
2 changes: 1 addition & 1 deletion src/modules/search_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def consistent_open(data_list, directory, timeout = 1):
# in the function is greater than timeout.
try:
f = os.path.join(directory, d.get_file_name())
fh = open(f, 'r')
fh = open(f, 'r', encoding='UTF-8')
# If we get here, then the current index file
# is present.
if missing == None:
Expand Down
1 change: 0 additions & 1 deletion src/pkg/manifests/package:pkg.p5m
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,3 @@ depend type=require fmri=library/python/pycurl-35
depend type=require fmri=library/python/pyopenssl-35
depend type=require fmri=library/python/rapidjson-35
depend type=require fmri=library/python/six-35
depend type=require fmri=locale/en