Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: benjaminp/six
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.13.0
Choose a base ref
...
head repository: benjaminp/six
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.14.0
Choose a head ref
  • 15 commits
  • 11 files changed
  • 5 contributors

Commits on Nov 5, 2019

  1. Copy the full SHA
    4309e80 View commit details

Commits on Nov 15, 2019

  1. Remove unused inner function. (#310)

    graingert authored and benjaminp committed Nov 15, 2019
    Copy the full SHA
    33b584b View commit details

Commits on Jan 7, 2020

  1. 10 years of six!

    benjaminp committed Jan 7, 2020
    Copy the full SHA
    a4d9af9 View commit details
  2. Fix wraps handing of missing attrs. (#251)

    This is pretty-much a straight backport of Py3 implementations of update_wrapper and (privately) wraps.
    
    Fixes #250 
    Fixes #165
    
    Co-authored-by: Benjamin Peterson <benjamin@python.org>
    immerrr and benjaminp committed Jan 7, 2020
    Copy the full SHA
    1988faf View commit details
  3. Changelog for #251.

    benjaminp committed Jan 7, 2020
    Copy the full SHA
    422fc7a View commit details

Commits on Jan 8, 2020

  1. Drop support for EOL Python 2.6 and 3.2. (#314)

    Fixes #308.
    
    Stops testing them on the CI, update python_requries and remove some code specifically for those versions.
    
    Not done anything to remove any six functionality that's only a benefit on those versions, that should be in a separate PR and would be a breaking change that should ideally deprecate first.
    hugovk authored and benjaminp committed Jan 8, 2020
    Copy the full SHA
    ac4bdc5 View commit details
  2. Copy the full SHA
    f4ccdb2 View commit details
  3. Copy the full SHA
    9e824c0 View commit details
  4. Copy the full SHA
    48ffe3c View commit details
  5. version -> version_info

    benjaminp committed Jan 8, 2020
    Copy the full SHA
    ab67534 View commit details
  6. New contributors.

    benjaminp committed Jan 8, 2020
    Copy the full SHA
    5cd83db View commit details

Commits on Jan 9, 2020

  1. Add assertNotRegex. (#289)

    Fixes #288.
    
    Co-authored-by: Benjamin Peterson <benjamin@python.org>
    jvanasco and benjaminp committed Jan 9, 2020
    Copy the full SHA
    10a2b75 View commit details
  2. Copy the full SHA
    c8e190c View commit details

Commits on Jan 15, 2020

  1. python-porting is dead.

    benjaminp committed Jan 15, 2020
    Copy the full SHA
    be13e64 View commit details
  2. six 1.14.0

    benjaminp committed Jan 15, 2020
    Copy the full SHA
    3a3db75 View commit details
Showing with 114 additions and 99 deletions.
  1. +2 −6 .travis.yml
  2. +14 −0 CHANGES
  3. +3 −0 CONTRIBUTORS
  4. +1 −1 LICENSE
  5. +1 −4 README.rst
  6. +1 −1 documentation/conf.py
  7. +11 −4 documentation/index.rst
  8. +2 −2 setup.py
  9. +37 −20 six.py
  10. +41 −60 test_six.py
  11. +1 −1 tox.ini
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ python:
- pypy
- pypy3
install:
- pip install --upgrade --force-reinstall "setuptools; python_version != '3.2' and python_version != '3.3'" "setuptools < 30; python_version == '3.2'" "setuptools < 40; python_version == '3.3'"
- 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==2.9.2 typing
- 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
@@ -26,10 +26,6 @@ script:
jobs:
fast_finish: true
include:
- python: 2.6
dist: trusty
- python: 3.2
dist: trusty
- python: 3.3
dist: trusty
- stage: upload new version of python package to PYPI (only for tagged commits)
14 changes: 14 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -3,6 +3,20 @@ Changelog for six

This file lists the changes in each six version.

1.14.0
------

- Issue #288, pull request #289: Add `six.assertNotRegex`.

- Issue #317: `six.moves._dummy_thread` now points to the `_thread` module on
Python 3.9+. Python 3.7 and later requires threading and deprecated the
`_dummy_thread` module.

- Issue #308, pull request #314: Remove support for Python 2.6 and Python 3.2.

- Issue #250, issue #165, pull request #251: `six.wraps` now ignores missing
attributes. This follows the Python 3.2+ standard library behavior.

1.13.0
------

3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ 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
@@ -20,6 +21,7 @@ Thomas Grainger
Max Grender-Jones
Joshua Harlow
Toshiki Kataoka
Hugo van Kemenade
Anselm Kruis
Ivan Levkivskyi
Alexander Lukanin
@@ -33,6 +35,7 @@ Peter Ruibal
Miroslav Shubernetskiy
Eli Schwartz
Anthony Sottile
Jonathan Vanasco
Lucas Wiman
Jingxin Zhu

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2010-2019 Benjamin Peterson
Copyright (c) 2010-2020 Benjamin Peterson

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
5 changes: 1 addition & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -19,14 +19,11 @@ 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 every Python version since 2.6. It is contained in only one Python
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.

For questions about six or porting in general, email the python-porting mailing
list: https://mail.python.org/mailman/listinfo/python-porting
2 changes: 1 addition & 1 deletion documentation/conf.py
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@

# General information about the project.
project = u"six"
copyright = u"2010-2019, Benjamin Peterson"
copyright = u"2010-2020, Benjamin Peterson"

sys.path.append(os.path.abspath(os.path.join(".", "..")))
from six import __version__ as six_version
15 changes: 11 additions & 4 deletions documentation/index.rst
Original file line number Diff line number Diff line change
@@ -257,9 +257,10 @@ functions and methods is the stdlib :mod:`py3:inspect` module.

.. decorator:: wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES)

This is exactly the :func:`py3:functools.wraps` decorator, but it sets the
``__wrapped__`` attribute on what it decorates as :func:`py3:functools.wraps`
does on Python versions after 3.2.
This is Python 3.2's :func:`py3:functools.wraps` decorator. It sets the
``__wrapped__`` attribute on what it decorates. It doesn't raise an error if
any of the attributes mentioned in ``assigned`` and ``updated`` are missing
on ``wrapped`` object.


Syntax compatibility
@@ -509,6 +510,11 @@ Note these functions are only available on Python 2.7 or later.
Alias for :meth:`~py3:unittest.TestCase.assertRegex` on Python 3 and
:meth:`~py2:unittest.TestCase.assertRegexpMatches` on Python 2.

.. function:: assertNotRegex()

Alias for :meth:`~py3:unittest.TestCase.assertNotRegex` on Python 3 and
:meth:`~py2:unittest.TestCase.assertNotRegexpMatches` on Python 2.


Renamed modules and attributes compatibility
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -590,7 +596,8 @@ Supported renames:
+------------------------------+-------------------------------------+---------------------------------------+
| ``dbm_ndbm`` | :mod:`py2:dbm` | :mod:`py3:dbm.ndbm` |
+------------------------------+-------------------------------------+---------------------------------------+
| ``_dummy_thread`` | :mod:`py2:dummy_thread` | :mod:`py3:_dummy_thread` |
| ``_dummy_thread`` | :mod:`py2:dummy_thread` | :mod:`py3:_dummy_thread` (< 3.9) |
| | | :mod:`py3:_thread` (3.9+) |
+------------------------------+-------------------------------------+---------------------------------------+
| ``email_mime_base`` | :mod:`py2:email.MIMEBase` | :mod:`py3:email.mime.base` |
+------------------------------+-------------------------------------+---------------------------------------+
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2019 Benjamin Peterson
# Copyright (c) 2010-2020 Benjamin Peterson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -54,5 +54,5 @@
long_description=six_long_description,
license="MIT",
classifiers=six_classifiers,
python_requires=">=2.6, !=3.0.*, !=3.1.*",
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*",
)
57 changes: 37 additions & 20 deletions six.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2019 Benjamin Peterson
# Copyright (c) 2010-2020 Benjamin Peterson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +29,7 @@
import types

__author__ = "Benjamin Peterson <benjamin@python.org>"
__version__ = "1.13.0"
__version__ = "1.14.0"


# Useful for very coarse version differentiation.
@@ -259,7 +259,7 @@ class _MovedItems(_LazyModule):
MovedModule("copyreg", "copy_reg"),
MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"),
MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread" if sys.version_info < (3, 9) else "_thread"),
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
MovedModule("http_cookies", "Cookie", "http.cookies"),
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
@@ -644,9 +644,11 @@ def u(s):
if sys.version_info[1] <= 1:
_assertRaisesRegex = "assertRaisesRegexp"
_assertRegex = "assertRegexpMatches"
_assertNotRegex = "assertNotRegexpMatches"
else:
_assertRaisesRegex = "assertRaisesRegex"
_assertRegex = "assertRegex"
_assertNotRegex = "assertNotRegex"
else:
def b(s):
return s
@@ -668,6 +670,7 @@ def indexbytes(buf, i):
_assertCountEqual = "assertItemsEqual"
_assertRaisesRegex = "assertRaisesRegexp"
_assertRegex = "assertRegexpMatches"
_assertNotRegex = "assertNotRegexpMatches"
_add_doc(b, """Byte literal""")
_add_doc(u, """Text literal""")

@@ -684,6 +687,10 @@ def assertRegex(self, *args, **kwargs):
return getattr(self, _assertRegex)(*args, **kwargs)


def assertNotRegex(self, *args, **kwargs):
return getattr(self, _assertNotRegex)(*args, **kwargs)


if PY3:
exec_ = getattr(moves.builtins, "exec")

@@ -719,16 +726,7 @@ def exec_(_code_, _globs_=None, _locs_=None):
""")


if sys.version_info[:2] == (3, 2):
exec_("""def raise_from(value, from_value):
try:
if from_value is None:
raise value
raise value from from_value
finally:
value = None
""")
elif sys.version_info[:2] > (3, 2):
if sys.version_info[:2] > (3,):
exec_("""def raise_from(value, from_value):
try:
raise value from from_value
@@ -808,13 +806,33 @@ def print_(*args, **kwargs):
_add_doc(reraise, """Reraise an exception.""")

if sys.version_info[0:2] < (3, 4):
# This does exactly the same what the :func:`py3:functools.update_wrapper`
# function does on Python versions after 3.2. It sets the ``__wrapped__``
# attribute on ``wrapper`` object and it doesn't raise an error if any of
# the attributes mentioned in ``assigned`` and ``updated`` are missing on
# ``wrapped`` object.
def _update_wrapper(wrapper, wrapped,
assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
for attr in assigned:
try:
value = getattr(wrapped, attr)
except AttributeError:
continue
else:
setattr(wrapper, attr, value)
for attr in updated:
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
wrapper.__wrapped__ = wrapped
return wrapper
_update_wrapper.__doc__ = functools.update_wrapper.__doc__

def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
def wrapper(f):
f = functools.wraps(wrapped, assigned, updated)(f)
f.__wrapped__ = wrapped
return f
return wrapper
return functools.partial(_update_wrapper, wrapped=wrapped,
assigned=assigned, updated=updated)
wraps.__doc__ = functools.wraps.__doc__

else:
wraps = functools.wraps

@@ -919,10 +937,9 @@ def ensure_text(s, encoding='utf-8', errors='strict'):
raise TypeError("not expecting type '%s'" % type(s))



def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
Loading