Skip to content

Commit

Permalink
Mark read_utf8_with_fallback as private
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Apr 21, 2024
1 parent aeac45b commit 9fd5981
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions setuptools/command/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from setuptools import namespaces
import setuptools

from ..unicode_utils import read_utf8_with_fallback
from ..unicode_utils import _read_utf8_with_fallback


class develop(namespaces.DevelopInstaller, easy_install):
Expand Down Expand Up @@ -133,7 +133,7 @@ def uninstall_link(self):

contents = [
line.rstrip()
for line in read_utf8_with_fallback(self.egg_link).splitlines()
for line in _read_utf8_with_fallback(self.egg_link).splitlines()
]

if contents not in ([self.egg_path], [self.egg_path, self.setup_path]):
Expand Down Expand Up @@ -161,7 +161,7 @@ def install_egg_scripts(self, dist):
for script_name in self.distribution.scripts or []:
script_path = os.path.abspath(convert_path(script_name))
script_name = os.path.basename(script_path)
script_text = read_utf8_with_fallback(script_path)
script_text = _read_utf8_with_fallback(script_path)
self.install_script(dist, script_name, script_text, script_path)

return None
Expand Down
4 changes: 2 additions & 2 deletions setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from setuptools.extern.more_itertools import unique_everseen

from .compat import py39
from .unicode_utils import read_utf8_with_fallback
from .unicode_utils import _read_utf8_with_fallback


EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.+!]+)$')
Expand Down Expand Up @@ -1121,7 +1121,7 @@ def local_open(url):
for f in os.listdir(filename):
filepath = os.path.join(filename, f)
if f == 'index.html':
body = read_utf8_with_fallback(filepath)
body = _read_utf8_with_fallback(filepath)
break
elif os.path.isdir(filepath):
f += '/'
Expand Down
2 changes: 1 addition & 1 deletion setuptools/unicode_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def try_encode(string, enc):
return None


def read_utf8_with_fallback(file: str, fallback_encoding=py39.LOCALE_ENCODING) -> str:
def _read_utf8_with_fallback(file: str, fallback_encoding=py39.LOCALE_ENCODING) -> str:
"""
First try to read the file with UTF-8, if there is an error fallback to a
different encoding ("locale" by default). Returns the content of the file.
Expand Down
4 changes: 2 additions & 2 deletions setuptools/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from setuptools.command.egg_info import write_requirements, _egg_basename
from setuptools.archive_util import _unpack_zipfile_obj

from .unicode_utils import read_utf8_with_fallback
from .unicode_utils import _read_utf8_with_fallback


WHEEL_NAME = re.compile(
Expand Down Expand Up @@ -224,7 +224,7 @@ def _move_data_entries(destination_eggdir, dist_data):
def _fix_namespace_packages(egg_info, destination_eggdir):
namespace_packages = os.path.join(egg_info, 'namespace_packages.txt')
if os.path.exists(namespace_packages):
namespace_packages = read_utf8_with_fallback(namespace_packages).split()
namespace_packages = _read_utf8_with_fallback(namespace_packages).split()

for mod in namespace_packages:
mod_dir = os.path.join(destination_eggdir, *mod.split('.'))
Expand Down

0 comments on commit 9fd5981

Please sign in to comment.