aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2018-09-16 09:10:00 -0400
committerGitHub <noreply@github.com>2018-09-16 09:10:00 -0400
commit40aabe3f9a153f66f3257e49ada7a983e3096c77 (patch)
treed6abfc4fbc96202d8dbb794ccc7cdc4bef661273
parent318d6b02c5f8fa86e60518b20c14b625e355b17e (diff)
parent4f165ed9d35ea7e37823bec25ed822338387c0be (diff)
downloadexternal_python_setuptools-40aabe3f9a153f66f3257e49ada7a983e3096c77.tar.gz
external_python_setuptools-40aabe3f9a153f66f3257e49ada7a983e3096c77.tar.bz2
external_python_setuptools-40aabe3f9a153f66f3257e49ada7a983e3096c77.zip
Merge pull request #1479 from jdufresne/bytes
Remove compatibility shim for bytes type
-rw-r--r--changelog.d/1479.misc.rst1
-rw-r--r--setuptools/glob.py14
-rw-r--r--setuptools/tests/files.py3
-rw-r--r--setuptools/tests/test_glob.py35
4 files changed, 43 insertions, 10 deletions
diff --git a/changelog.d/1479.misc.rst b/changelog.d/1479.misc.rst
new file mode 100644
index 00000000..b04b0ce1
--- /dev/null
+++ b/changelog.d/1479.misc.rst
@@ -0,0 +1 @@
+Remove internal use of six.binary_type
diff --git a/setuptools/glob.py b/setuptools/glob.py
index 6c781de3..9d7cbc5d 100644
--- a/setuptools/glob.py
+++ b/setuptools/glob.py
@@ -3,14 +3,12 @@ Filename globbing utility. Mostly a copy of `glob` from Python 3.5.
Changes include:
* `yield from` and PEP3102 `*` removed.
- * `bytes` changed to `six.binary_type`.
* Hidden files are not ignored.
"""
import os
import re
import fnmatch
-from setuptools.extern.six import binary_type
__all__ = ["glob", "iglob", "escape"]
@@ -92,7 +90,7 @@ def _iglob(pathname, recursive):
def glob1(dirname, pattern):
if not dirname:
- if isinstance(pattern, binary_type):
+ if isinstance(pattern, bytes):
dirname = os.curdir.encode('ASCII')
else:
dirname = os.curdir
@@ -129,8 +127,8 @@ def glob2(dirname, pattern):
# Recursively yields relative pathnames inside a literal directory.
def _rlistdir(dirname):
if not dirname:
- if isinstance(dirname, binary_type):
- dirname = binary_type(os.curdir, 'ASCII')
+ if isinstance(dirname, bytes):
+ dirname = os.curdir.encode('ASCII')
else:
dirname = os.curdir
try:
@@ -149,7 +147,7 @@ magic_check_bytes = re.compile(b'([*?[])')
def has_magic(s):
- if isinstance(s, binary_type):
+ if isinstance(s, bytes):
match = magic_check_bytes.search(s)
else:
match = magic_check.search(s)
@@ -157,7 +155,7 @@ def has_magic(s):
def _isrecursive(pattern):
- if isinstance(pattern, binary_type):
+ if isinstance(pattern, bytes):
return pattern == b'**'
else:
return pattern == '**'
@@ -169,7 +167,7 @@ def escape(pathname):
# Escaping is done by wrapping any of "*?[" between square brackets.
# Metacharacters do not work in the drive part and shouldn't be escaped.
drive, pathname = os.path.splitdrive(pathname)
- if isinstance(pathname, binary_type):
+ if isinstance(pathname, bytes):
pathname = magic_check_bytes.sub(br'[\1]', pathname)
else:
pathname = magic_check.sub(r'[\1]', pathname)
diff --git a/setuptools/tests/files.py b/setuptools/tests/files.py
index f5f0e6bb..465a6b41 100644
--- a/setuptools/tests/files.py
+++ b/setuptools/tests/files.py
@@ -1,7 +1,6 @@
import os
-from setuptools.extern.six import binary_type
import pkg_resources.py31compat
@@ -31,7 +30,7 @@ def build_files(file_defs, prefix=""):
pkg_resources.py31compat.makedirs(full_name, exist_ok=True)
build_files(contents, prefix=full_name)
else:
- if isinstance(contents, binary_type):
+ if isinstance(contents, bytes):
with open(full_name, 'wb') as f:
f.write(contents)
else:
diff --git a/setuptools/tests/test_glob.py b/setuptools/tests/test_glob.py
new file mode 100644
index 00000000..a0728c5d
--- /dev/null
+++ b/setuptools/tests/test_glob.py
@@ -0,0 +1,35 @@
+import pytest
+
+from setuptools.glob import glob
+
+from .files import build_files
+
+
+@pytest.mark.parametrize('tree, pattern, matches', (
+ ('', b'', []),
+ ('', '', []),
+ ('''
+ appveyor.yml
+ CHANGES.rst
+ LICENSE
+ MANIFEST.in
+ pyproject.toml
+ README.rst
+ setup.cfg
+ setup.py
+ ''', '*.rst', ('CHANGES.rst', 'README.rst')),
+ ('''
+ appveyor.yml
+ CHANGES.rst
+ LICENSE
+ MANIFEST.in
+ pyproject.toml
+ README.rst
+ setup.cfg
+ setup.py
+ ''', b'*.rst', (b'CHANGES.rst', b'README.rst')),
+))
+def test_glob(monkeypatch, tmpdir, tree, pattern, matches):
+ monkeypatch.chdir(tmpdir)
+ build_files({name: '' for name in tree.split()})
+ assert list(sorted(glob(pattern))) == list(sorted(matches))