Imported Upstream version 1.15.0 upstream upstream/1.15.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 4 Jan 2021 06:35:07 +0000 (15:35 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 4 Jan 2021 06:35:07 +0000 (15:35 +0900)
13 files changed:
.gitignore [deleted file]
.travis.yml [deleted file]
CHANGES
CONTRIBUTORS [deleted file]
PKG-INFO [new file with mode: 0644]
documentation/index.rst
setup.cfg
six.egg-info/PKG-INFO [new file with mode: 0644]
six.egg-info/SOURCES.txt [new file with mode: 0644]
six.egg-info/dependency_links.txt [new file with mode: 0644]
six.egg-info/top_level.txt [new file with mode: 0644]
six.py
tox.ini [deleted file]

diff --git a/.gitignore b/.gitignore
deleted file mode 100644 (file)
index d4b534b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-*.pyc
-build
-dist
-MANIFEST
-documentation/_build
-.tox
-six.egg-info
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644 (file)
index 772aeff..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-os: linux
-dist: xenial
-language: python
-python:
-- 2.7
-- 3.4
-- 3.5
-- 3.6
-- 3.7
-- &mainstream_python 3.8
-- nightly
-- pypy
-- pypy3
-install:
-- pip install --upgrade --force-reinstall "setuptools; python_version != '3.3'" "setuptools < 40; python_version == '3.3'"
-- pip uninstall --yes six || true
-- pip install --upgrade --force-reinstall --ignore-installed -e .
-- pip install "pytest==4.6.9; python_version != '3.3'" "pytest==2.9.2; python_version == '3.3'" typing
-- &py_pkg_list pip list --format=columns || pip list
-script:
-- py.test
-- echo Checking whether installation flow is not broken...
-- pip uninstall --yes six || true
-- pip install --ignore-installed .
-- *py_pkg_list
-jobs:
-  fast_finish: true
-  include:
-  - python: 3.3
-    dist: trusty
-  - stage: upload new version of python package to PYPI (only for tagged commits)
-    python: *mainstream_python
-    install: skip
-    script: skip
-    deploy:
-      provider: pypi
-      on:
-        tags: true
-        all_branches: true
-        python: *mainstream_python
-      user: gutworth
-      distributions: "sdist bdist_wheel"
-      password:
-        secure: NPhfQT7XnZb0r0hKGWBwpHPXYpe3diD8aQXaUUq7+Y/iLAk5PhoFCRz+lPqnu7HiQcC2mcdzz3fvvRmj9IR/4EJj/+hkAfUeK4utwhXojSovEyk7VM/sUoT8hK4x++42sqbTvu2UcoSabTMEdFXC/Rhg/HHmOYzRMONJF2l8NGLsOu+t+BM6ruMZbmteGcquedi6JcOOAx7KR8dZ5vY387HwMyZg8yis4Qp7fSSivLzjV5i60ZDE4GzbD0XXywc+dxvl6KnLvJN4ApwnDRgTDsPU7OuEG09od0kVELhxsvwvKh47iBor0vVWCLb+sOgQj+EgMVZNqbghvTdQZMR/D4CADKBHHYZcCS7PuesbXfP4/USzDHPQB1i9bPMo7heRJpOfAt09SC49MJ6F1oEXkDWizN64Q9S3C0ZZvl4oDRcBxOYv17QyCM88ezhokadF2anVz+qEG7QINDrpq0qDGYnvb+1m7iZkGELnbmYPN3vu4Kow2LQkIE2tomv6Hvd/NTCEXHoPBybNE2LhmfrN6tdpkT0DDAg2PCnexcl+usZArHYuA/chX1IuhmxrQCeVVhSiVdxldR3XRjmavYcNhLsYP9upxEGEtQw7zR8vIw+WDlZmR+UN44sjTQCescAznZyxlqBtB6heW5CkrtiMjcmwKplCccsPHwWrkKOSb6w=
-cache:
-  pip: true
-after_failure:
-- echo "Here's a list of installed Python packages:"
-- *py_pkg_list
diff --git a/CHANGES b/CHANGES
index 63eb48e..ad4cbaa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,11 @@ Changelog for six
 
 This file lists the changes in each six version.
 
+1.15.0
+------
+
+- Pull request #331: Optimize `six.ensure_str` and `six.ensure_binary`.
+
 1.14.0
 ------
 
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
deleted file mode 100644 (file)
index 4480c34..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-The primary author and maintainer of six is Benjamin Peterson. He would like to
-acknowledge the following people who submitted bug reports, pull requests, and
-otherwise worked to improve six:
-
-Marc Abramowitz
-immerrr again
-Alexander Artemenko
-Aymeric Augustin
-Lee Ball
-Ben Bariteau
-Ned Batchelder
-Wouter Bolsterlee
-Brett Cannon
-Jason R. Coombs
-Julien Danjou
-Ben Darnell
-Ben Davis
-Jon Dufresne
-Tim Graham
-Thomas Grainger
-Max Grender-Jones
-Joshua Harlow
-Toshiki Kataoka
-Hugo van Kemenade
-Anselm Kruis
-Ivan Levkivskyi
-Alexander Lukanin
-James Mills
-Jordan Moldow
-Berker Peksag
-Sridhar Ratnakumar
-Erik Rose
-Mirko Rossini
-Peter Ruibal
-Miroslav Shubernetskiy
-Eli Schwartz
-Anthony Sottile
-Jonathan Vanasco
-Lucas Wiman
-Jingxin Zhu
-
-If you think you belong on this list, please let me know! --Benjamin
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644 (file)
index 0000000..75aba67
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,47 @@
+Metadata-Version: 1.2
+Name: six
+Version: 1.15.0
+Summary: Python 2 and 3 compatibility utilities
+Home-page: https://github.com/benjaminp/six
+Author: Benjamin Peterson
+Author-email: benjamin@python.org
+License: MIT
+Description: .. image:: https://img.shields.io/pypi/v/six.svg
+           :target: https://pypi.org/project/six/
+           :alt: six on PyPI
+        
+        .. image:: https://travis-ci.org/benjaminp/six.svg?branch=master
+           :target: https://travis-ci.org/benjaminp/six
+           :alt: six on TravisCI
+        
+        .. image:: https://readthedocs.org/projects/six/badge/?version=latest
+           :target: https://six.readthedocs.io/
+           :alt: six's documentation on Read the Docs
+        
+        .. image:: https://img.shields.io/badge/license-MIT-green.svg
+           :target: https://github.com/benjaminp/six/blob/master/LICENSE
+           :alt: MIT License badge
+        
+        Six is a Python 2 and 3 compatibility library.  It provides utility functions
+        for smoothing over the differences between the Python versions with the goal of
+        writing Python code that is compatible on both Python versions.  See the
+        documentation for more information on what is provided.
+        
+        Six supports Python 2.7 and 3.3+.  It is contained in only one Python
+        file, so it can be easily copied into your project. (The copyright and license
+        notice must be retained.)
+        
+        Online documentation is at https://six.readthedocs.io/.
+        
+        Bugs can be reported to https://github.com/benjaminp/six.  The code can also
+        be found there.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Utilities
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*
index e2e82e3..45390b8 100644 (file)
@@ -452,7 +452,7 @@ string data in all Python versions.
 .. function:: ensure_text(s, encoding='utf-8', errors='strict')
 
    Coerce *s* to :data:`text_type`. *encoding*, *errors* are the same as
-   :meth:`py3:str.encode`
+   :meth:`py3:bytes.decode`
 
 
 .. data:: StringIO
index 317e016..fb1f536 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,12 +9,16 @@ ignore = F821
 license_file = LICENSE
 
 [tool:pytest]
-minversion=2.2.0
-pep8ignore =
-    documentation/*.py ALL
-    test_six.py ALL
+minversion = 2.2.0
+pep8ignore = 
+       documentation/*.py ALL
+       test_six.py ALL
+flakes-ignore = 
+       documentation/*.py ALL
+       test_six.py ALL
+       six.py UndefinedName
+
+[egg_info]
+tag_build = 
+tag_date = 0
 
-flakes-ignore =
-    documentation/*.py ALL
-    test_six.py ALL
-    six.py UndefinedName
diff --git a/six.egg-info/PKG-INFO b/six.egg-info/PKG-INFO
new file mode 100644 (file)
index 0000000..75aba67
--- /dev/null
@@ -0,0 +1,47 @@
+Metadata-Version: 1.2
+Name: six
+Version: 1.15.0
+Summary: Python 2 and 3 compatibility utilities
+Home-page: https://github.com/benjaminp/six
+Author: Benjamin Peterson
+Author-email: benjamin@python.org
+License: MIT
+Description: .. image:: https://img.shields.io/pypi/v/six.svg
+           :target: https://pypi.org/project/six/
+           :alt: six on PyPI
+        
+        .. image:: https://travis-ci.org/benjaminp/six.svg?branch=master
+           :target: https://travis-ci.org/benjaminp/six
+           :alt: six on TravisCI
+        
+        .. image:: https://readthedocs.org/projects/six/badge/?version=latest
+           :target: https://six.readthedocs.io/
+           :alt: six's documentation on Read the Docs
+        
+        .. image:: https://img.shields.io/badge/license-MIT-green.svg
+           :target: https://github.com/benjaminp/six/blob/master/LICENSE
+           :alt: MIT License badge
+        
+        Six is a Python 2 and 3 compatibility library.  It provides utility functions
+        for smoothing over the differences between the Python versions with the goal of
+        writing Python code that is compatible on both Python versions.  See the
+        documentation for more information on what is provided.
+        
+        Six supports Python 2.7 and 3.3+.  It is contained in only one Python
+        file, so it can be easily copied into your project. (The copyright and license
+        notice must be retained.)
+        
+        Online documentation is at https://six.readthedocs.io/.
+        
+        Bugs can be reported to https://github.com/benjaminp/six.  The code can also
+        be found there.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Utilities
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*
diff --git a/six.egg-info/SOURCES.txt b/six.egg-info/SOURCES.txt
new file mode 100644 (file)
index 0000000..9a7f3de
--- /dev/null
@@ -0,0 +1,15 @@
+CHANGES
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+six.py
+test_six.py
+documentation/Makefile
+documentation/conf.py
+documentation/index.rst
+six.egg-info/PKG-INFO
+six.egg-info/SOURCES.txt
+six.egg-info/dependency_links.txt
+six.egg-info/top_level.txt
\ No newline at end of file
diff --git a/six.egg-info/dependency_links.txt b/six.egg-info/dependency_links.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/six.egg-info/top_level.txt b/six.egg-info/top_level.txt
new file mode 100644 (file)
index 0000000..ffe2fce
--- /dev/null
@@ -0,0 +1 @@
+six
diff --git a/six.py b/six.py
index 5fe9f8e..83f6978 100644 (file)
--- a/six.py
+++ b/six.py
@@ -29,7 +29,7 @@ import sys
 import types
 
 __author__ = "Benjamin Peterson <benjamin@python.org>"
-__version__ = "1.14.0"
+__version__ = "1.15.0"
 
 
 # Useful for very coarse version differentiation.
@@ -890,12 +890,11 @@ def ensure_binary(s, encoding='utf-8', errors='strict'):
       - `str` -> encoded to `bytes`
       - `bytes` -> `bytes`
     """
+    if isinstance(s, binary_type):
+        return s
     if isinstance(s, text_type):
         return s.encode(encoding, errors)
-    elif isinstance(s, binary_type):
-        return s
-    else:
-        raise TypeError("not expecting type '%s'" % type(s))
+    raise TypeError("not expecting type '%s'" % type(s))
 
 
 def ensure_str(s, encoding='utf-8', errors='strict'):
@@ -909,12 +908,15 @@ def ensure_str(s, encoding='utf-8', errors='strict'):
       - `str` -> `str`
       - `bytes` -> decoded to `str`
     """
-    if not isinstance(s, (text_type, binary_type)):
-        raise TypeError("not expecting type '%s'" % type(s))
+    # Optimization: Fast return for the common case.
+    if type(s) is str:
+        return s
     if PY2 and isinstance(s, text_type):
-        s = s.encode(encoding, errors)
+        return s.encode(encoding, errors)
     elif PY3 and isinstance(s, binary_type):
-        s = s.decode(encoding, errors)
+        return s.decode(encoding, errors)
+    elif not isinstance(s, (text_type, binary_type)):
+        raise TypeError("not expecting type '%s'" % type(s))
     return s
 
 
diff --git a/tox.ini b/tox.ini
deleted file mode 100644 (file)
index a1e3467..0000000
--- a/tox.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[tox]
-envlist=py27,py33,py34,py35,py36,py37,py38,pypy,flake8
-
-[testenv]
-deps= pytest
-commands= python -m pytest -rfsxX {posargs}
-
-[testenv:flake8]
-basepython=python
-deps=flake8
-commands= flake8 six.py