Skip to content

Commit

Permalink
Merge 23fa3c6 into 6595ce1
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Oct 12, 2019
2 parents 6595ce1 + 23fa3c6 commit 5a15f31
Show file tree
Hide file tree
Showing 156 changed files with 589 additions and 1,489 deletions.
5 changes: 0 additions & 5 deletions .appveyor.yml
Expand Up @@ -44,11 +44,6 @@ install:
- xcopy c:\pillow-depends\*.tar.gz c:\pillow\winbuild\
- xcopy /s c:\pillow-depends\test_images\* c:\pillow\tests\images
- cd c:\pillow\winbuild\
- ps: |
if ($env:PYTHON -eq "c:/vp/pypy2")
{
c:\pillow\winbuild\appveyor_install_pypy2.cmd
}
- ps: |
if ($env:PYTHON -eq "c:/vp/pypy3")
{
Expand Down
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Expand Up @@ -9,14 +9,14 @@ Please send a pull request to the master branch. Please include [documentation](
- Fork the Pillow repository.
- Create a branch from master.
- Develop bug fixes, features, tests, etc.
- Run the test suite on Python 2.7 and 3.x. You can enable [Travis CI](https://travis-ci.org/profile/) and [AppVeyor](https://ci.appveyor.com/projects/new) on your repo to catch test failures prior to the pull request, and [Codecov](https://codecov.io/gh) to see if the changed code is covered by tests.
- Run the test suite. You can enable [Travis CI](https://travis-ci.org/profile/) and [AppVeyor](https://ci.appveyor.com/projects/new) on your repo to catch test failures prior to the pull request, and [Codecov](https://codecov.io/gh) to see if the changed code is covered by tests.
- Create a pull request to pull the changes from your branch to the Pillow master.

### Guidelines

- Separate code commits from reformatting commits.
- Provide tests for any newly added code.
- Follow PEP8.
- Follow PEP 8.
- When committing only documentation changes please include [ci skip] in the commit message to avoid running tests on Travis-CI and AppVeyor.

## Reporting Issues
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -6,8 +6,8 @@ notifications:
irc: "chat.freenode.net#pil"

# Run fast lint first to get fast feedback.
# Run slow PyPy* next, to give them a headstart and reduce waiting time.
# Run latest 3.x and 2.x next, to get quick compatibility results.
# Run slow PyPy next, to give it a headstart and reduce waiting time.
# Run latest 3.x next, to get quick compatibility results.
# Then run the remainder, with fastest Docker jobs last.

matrix:
Expand Down
10 changes: 3 additions & 7 deletions .travis/after_success.sh
Expand Up @@ -11,16 +11,12 @@ coveralls-lcov -v -n coverage.filtered.info > coverage.c.json

coverage report
pip install codecov
if [[ $TRAVIS_PYTHON_VERSION != "2.7_with_system_site_packages" ]]; then
# Not working here. Just skip it, it's being removed soon.
pip install coveralls-merge
coveralls-merge coverage.c.json
fi
pip install coveralls-merge
coveralls-merge coverage.c.json
codecov

if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] && [ "$DOCKER" == "" ]; then
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ] && [ "$DOCKER" == "" ]; then
# Coverage and quality reports on just the latest diff.
# (Installation is very slow on Py3, so just do it for Py2.)
depends/diffcover-install.sh
depends/diffcover-run.sh
fi
4 changes: 2 additions & 2 deletions .travis/install.sh
Expand Up @@ -20,8 +20,8 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.* ]]; then
pip install pyqt5
fi

# docs only on Python 2.7
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then pip install -r requirements.txt ; fi
# docs only on Python 3.7
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ]; then pip install -r requirements.txt ; fi

# webp
pushd depends && ./install_webp.sh && popd
Expand Down
2 changes: 1 addition & 1 deletion .travis/test.sh
Expand Up @@ -5,4 +5,4 @@ set -e
python -m pytest -v -x --cov PIL --cov-report term Tests

# Docs
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then make doccheck; fi
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ]; then make doccheck; fi
36 changes: 18 additions & 18 deletions Makefile
Expand Up @@ -3,7 +3,7 @@
.DEFAULT_GOAL := release-test

clean:
python setup.py clean
python3 setup.py clean
rm src/PIL/*.so || true
rm -r build || true
find . -name __pycache__ | xargs rm -r || true
Expand All @@ -15,8 +15,8 @@ co:
done

coverage:
python selftest.py
python setup.py test
python3 selftest.py
python3 setup.py test
rm -r htmlcov || true
coverage report

Expand All @@ -30,7 +30,7 @@ doccheck:
$(MAKE) -C docs linkcheck || true

docserve:
cd docs/_build/html && python -mSimpleHTTPServer 2> /dev/null&
cd docs/_build/html && python3 -mSimpleHTTPServer 2> /dev/null&

help:
@echo "Welcome to Pillow development. Please use \`make <target>\` where <target> is one of"
Expand All @@ -50,22 +50,22 @@ help:
@echo " upload-test build and upload sdists to test.pythonpackages.com"

inplace: clean
python setup.py develop build_ext --inplace
python3 setup.py develop build_ext --inplace

install:
python setup.py install
python selftest.py
python3 setup.py install
python3 selftest.py

install-coverage:
CFLAGS="-coverage" python setup.py build_ext install
python selftest.py
CFLAGS="-coverage" python3 setup.py build_ext install
python3 selftest.py

debug:
# make a debug version if we don't have a -dbg python. Leaves in symbols
# for our stuff, kills optimization, and redirects to dev null so we
# see any build failures.
make clean > /dev/null
CFLAGS='-g -O0' python setup.py build_ext install > /dev/null
CFLAGS='-g -O0' python3 setup.py build_ext install > /dev/null

install-req:
pip install -r requirements.txt
Expand All @@ -76,17 +76,17 @@ install-venv:

release-test:
$(MAKE) install-req
python setup.py develop
python selftest.py
python -m pytest Tests
python setup.py install
python -m pytest -qq
python3 setup.py develop
python3 selftest.py
python3 -m pytest Tests
python3 setup.py install
python3 -m pytest -qq
check-manifest
pyroma .
viewdoc

sdist:
python setup.py sdist --format=gztar
python3 setup.py sdist --format=gztar

test:
pytest -qq
Expand All @@ -97,10 +97,10 @@ upload-test:
# username:
# password:
# repository = http://test.pythonpackages.com
python setup.py sdist --format=gztar upload -r test
python3 setup.py sdist --format=gztar upload -r test

upload:
python setup.py sdist --format=gztar upload
python3 setup.py sdist --format=gztar upload

readme:
viewdoc
3 changes: 0 additions & 3 deletions Tests/check_imaging_leaks.py
@@ -1,7 +1,4 @@
#!/usr/bin/env python

from __future__ import division

from PIL import Image

from .helper import PillowTestCase, is_win32, unittest
Expand Down
2 changes: 0 additions & 2 deletions Tests/createfontdatachunk.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function

import base64
import os

Expand Down
45 changes: 22 additions & 23 deletions Tests/helper.py
@@ -1,7 +1,6 @@
"""
Helper functions.
"""
from __future__ import print_function

import logging
import os
Expand All @@ -12,7 +11,6 @@
from io import BytesIO

from PIL import Image, ImageMath
from PIL._util import py3

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -80,31 +78,38 @@ def delete_tempfile(self, path):
def assert_deep_equal(self, a, b, msg=None):
try:
self.assertEqual(
len(a), len(b), msg or "got length %s, expected %s" % (len(a), len(b))
len(a),
len(b),
msg or "got length {}, expected {}".format(len(a), len(b)),
)
self.assertTrue(
all(x == y for x, y in zip(a, b)), msg or "got %s, expected %s" % (a, b)
all(x == y for x, y in zip(a, b)),
msg or "got {}, expected {}".format(a, b),
)
except Exception:
self.assertEqual(a, b, msg)

def assert_image(self, im, mode, size, msg=None):
if mode is not None:
self.assertEqual(
im.mode, mode, msg or "got mode %r, expected %r" % (im.mode, mode)
im.mode,
mode,
msg or "got mode {!r}, expected {!r}".format(im.mode, mode),
)

if size is not None:
self.assertEqual(
im.size, size, msg or "got size %r, expected %r" % (im.size, size)
im.size,
size,
msg or "got size {!r}, expected {!r}".format(im.size, size),
)

def assert_image_equal(self, a, b, msg=None):
self.assertEqual(
a.mode, b.mode, msg or "got mode %r, expected %r" % (a.mode, b.mode)
a.mode, b.mode, msg or "got mode {!r}, expected {!r}".format(a.mode, b.mode)
)
self.assertEqual(
a.size, b.size, msg or "got size %r, expected %r" % (a.size, b.size)
a.size, b.size, msg or "got size {!r}, expected {!r}".format(a.size, b.size)
)
if a.tobytes() != b.tobytes():
if HAS_UPLOADER:
Expand All @@ -125,10 +130,10 @@ def assert_image_equal_tofile(self, a, filename, msg=None, mode=None):
def assert_image_similar(self, a, b, epsilon, msg=None):
epsilon = float(epsilon)
self.assertEqual(
a.mode, b.mode, msg or "got mode %r, expected %r" % (a.mode, b.mode)
a.mode, b.mode, msg or "got mode {!r}, expected {!r}".format(a.mode, b.mode)
)
self.assertEqual(
a.size, b.size, msg or "got size %r, expected %r" % (a.size, b.size)
a.size, b.size, msg or "got size {!r}, expected {!r}".format(a.size, b.size)
)

a, b = convert_to_comparable(a, b)
Expand Down Expand Up @@ -231,12 +236,12 @@ def tempfile(self, template):

def open_withImagemagick(self, f):
if not imagemagick_available():
raise IOError()
raise OSError()

outfile = self.tempfile("temp.png")
if command_succeeds([IMCONVERT, f, outfile]):
return Image.open(outfile)
raise IOError()
raise OSError()


@unittest.skipIf(sys.platform.startswith("win32"), "requires Unix or macOS")
Expand Down Expand Up @@ -279,11 +284,6 @@ def _test_leak(self, core):

# helpers

if not py3:
# Remove DeprecationWarning in Python 3
PillowTestCase.assertRaisesRegex = PillowTestCase.assertRaisesRegexp
PillowTestCase.assertRegex = PillowTestCase.assertRegexpMatches


def fromstring(data):
return Image.open(BytesIO(data))
Expand Down Expand Up @@ -321,11 +321,10 @@ def command_succeeds(cmd):
Runs the command, which must be a list of strings. Returns True if the
command succeeds, or False if an OSError was raised by subprocess.Popen.
"""
with open(os.devnull, "wb") as f:
try:
subprocess.call(cmd, stdout=f, stderr=subprocess.STDOUT)
except OSError:
return False
try:
subprocess.call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
except OSError:
return False
return True


Expand Down Expand Up @@ -388,7 +387,7 @@ def distro():
return line.strip().split("=")[1]


class cached_property(object):
class cached_property:
def __init__(self, func):
self.func = func

Expand Down
2 changes: 0 additions & 2 deletions Tests/import_all.py
@@ -1,5 +1,3 @@
from __future__ import print_function

import glob
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions Tests/make_hash.py
@@ -1,7 +1,5 @@
# brute-force search for access descriptor hash table

from __future__ import print_function

modes = [
"1",
"L",
Expand Down
4 changes: 1 addition & 3 deletions Tests/test_bmp_reference.py
@@ -1,5 +1,3 @@
from __future__ import print_function

import os

from PIL import Image
Expand Down Expand Up @@ -109,4 +107,4 @@ def get_compare(f):
os.path.join(base, "g", "pal4rle.bmp"),
)
if f not in unsupported:
self.fail("Unsupported Image %s: %s" % (f, msg))
self.fail("Unsupported Image {}: {}".format(f, msg))
2 changes: 0 additions & 2 deletions Tests/test_color_lut.py
@@ -1,5 +1,3 @@
from __future__ import division

from array import array

from PIL import Image, ImageFilter
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_core_resources.py
@@ -1,5 +1,3 @@
from __future__ import division, print_function

import sys

from PIL import Image
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_features.py
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import io

from PIL import features
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_eps.py
Expand Up @@ -92,7 +92,7 @@ def test_file_object(self):
def test_iobase_object(self):
# issue 479
image1 = Image.open(file1)
with io.open(self.tempfile("temp_iobase.eps"), "wb") as fh:
with open(self.tempfile("temp_iobase.eps"), "wb") as fh:
image1.save(fh, "EPS")

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
Expand Down

0 comments on commit 5a15f31

Please sign in to comment.