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

Read UTF-8 data as UTF-8 #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions _setup/py3/setup.py
Expand Up @@ -27,6 +27,7 @@
import configparser as _config_parser
from distutils import core as _core
import os as _os
import io as _io
import posixpath as _posixpath
import sys as _sys

Expand Down Expand Up @@ -88,7 +89,7 @@ def find_description(docs):
summary = None
filename = docs.get('meta.summary', 'SUMMARY').strip()
if filename and _os.path.isfile(filename):
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
try:
summary = fp.read().strip().splitlines()[0].rstrip()
Expand All @@ -100,7 +101,7 @@ def find_description(docs):
description = None
filename = docs.get('meta.description', 'DESCRIPTION').strip()
if filename and _os.path.isfile(filename):
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
description = fp.read().rstrip()
finally:
Expand All @@ -126,7 +127,7 @@ def find_classifiers(docs):
"""
filename = docs.get('meta.classifiers', 'CLASSIFIERS').strip()
if filename and _os.path.isfile(filename):
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
content = fp.read()
finally:
Expand All @@ -145,7 +146,7 @@ def find_provides(docs):
"""
filename = docs.get('meta.provides', 'PROVIDES').strip()
if filename and _os.path.isfile(filename):
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
content = fp.read()
finally:
Expand All @@ -164,7 +165,7 @@ def find_license(docs):
"""
filename = docs.get('meta.license', 'LICENSE').strip()
if filename and _os.path.isfile(filename):
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
return fp.read().rstrip()
finally:
Expand Down Expand Up @@ -339,7 +340,7 @@ def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0):
ext = []

cfg = _util.SafeConfigParser()
cfg.read(config)
cfg.read(config, encoding="utf8")
pkg = dict(cfg.items('package'))
python_min = pkg.get('python.min') or None
python_max = pkg.get('python.max') or None
Expand Down
25 changes: 13 additions & 12 deletions make.py
Expand Up @@ -28,6 +28,7 @@

import errno as _errno
import os as _os
import io as _io
import re as _re
import sys as _sys

Expand Down Expand Up @@ -261,19 +262,19 @@ def run(self):
filename = _os.path.join(
self.dirs['_website'], 'src', 'website_download.txt'
)
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
download = fp.read()
finally:
fp.close()
filename = _os.path.join(self.dirs['_website'], 'src', 'index.txt')
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
indexlines = fp.readlines()
finally:
fp.close()

fp = open(filename, 'w')
fp = _io.open(filename, 'w', encoding="utf8")
try:
for line in indexlines:
if line.startswith('.. placeholder: Download'):
Expand All @@ -294,7 +295,7 @@ def run(self):
)
fp = open(_os.path.join(
self.dirs['_website'], 'src', 'conf.py'
), 'a')
), 'a', encoding="utf8")
try:
fp.write("\nepydoc = dict(rjsmin=%r)\n" % (
_os.path.join(
Expand Down Expand Up @@ -496,12 +497,12 @@ def run(self):
def _version_init(self, strversion):
""" Modify version in __init__ """
filename = _os.path.join(self.dirs['lib'], 'rjsmin.py')
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
initlines = fp.readlines()
finally:
fp.close()
fp = open(filename, 'w')
fp = _io.open(filename, 'w', encoding="utf8")
replaced = False
try:
for line in initlines:
Expand All @@ -516,12 +517,12 @@ def _version_init(self, strversion):
def _version_changes(self, strversion):
""" Modify version in changes """
filename = _os.path.join(shell.native(self.dirs['docs']), 'CHANGES')
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
initlines = fp.readlines()
finally:
fp.close()
fp = open(filename, 'w')
fp = _io.open(filename, 'w', encoding="utf8")
try:
for line in initlines:
if line.rstrip() == "Changes with version":
Expand All @@ -535,13 +536,13 @@ def _version_userdoc(self, strversion):
filename = _os.path.join(self.dirs['userdoc_source'], 'conf.py')
shortversion = '.'.join(strversion.split('.')[:2])
longversion = strversion
fp = open(filename)
fp = _io.open(filename, encoding="utf8")
try:
initlines = fp.readlines()
finally:
fp.close()
replaced = 0
fp = open(filename, 'w')
fp = _io.open(filename, 'w', encoding="utf8")
try:
for line in initlines:
if line.startswith('version'):
Expand All @@ -561,13 +562,13 @@ def _version_download(self, strversion):
self.dirs['userdoc_source'], 'website_download.txt'
)
VERSION, PATH = strversion, ''
fp = open(filename + '.in')
fp = _io.open(filename + '.in', encoding="utf8")
try:
dllines = fp.readlines()
finally:
fp.close()
instable = []
fp = open(filename, 'w')
fp = _io.open(filename, 'w', encoding="utf8")
try:
for line in dllines:
if instable:
Expand Down