Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim trailing whitespace from all source files throughout project #2892

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.

The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as plone, Django, or buildout, try to replicate the issue just using Pillow.
The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as plone, Django, or buildout, try to replicate the issue just using Pillow.

```python
code goes here
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ docs/_build/

#OS
.DS_Store

1 change: 0 additions & 1 deletion .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ pushd depends && ./install_imagequant.sh && popd

# extra test images
pushd depends && ./install_extra_test_images.sh && popd

1 change: 0 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Changelog (Pillow)
==================

Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

include *.c
include *.h
include *.in
Expand Down
2 changes: 1 addition & 1 deletion PIL/DcxImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DcxImageFile(PcxImageFile):
format = "DCX"
format_description = "Intel DCX"
_close_exclusive_fp_after_loading = False

def _open(self):

# Header
Expand Down
2 changes: 1 addition & 1 deletion PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ def transform(self, size, method, data=None, resample=NEAREST,
in the output image.
:returns: An :py:class:`~PIL.Image.Image` object.
"""

if self.mode == 'LA':
return self.convert('La').transform(
size, method, data, resample, fill).convert('LA')
Expand Down
2 changes: 1 addition & 1 deletion PIL/ImageTk.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __str__(self):

def getimage(photo):
""" This function is unimplemented """

"""Copies the contents of a PhotoImage to a PIL image memory."""
photo.tk.call("PyImagingPhotoGet", photo)

Expand Down
2 changes: 1 addition & 1 deletion PIL/MpoImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
format = "MPO"
format_description = "MPO (CIPA DC-007)"
_close_exclusive_fp_after_loading = False

def _open(self):
self.fp.seek(0) # prep the fp in order to pass the JPEG test
JpegImagePlugin.JpegImageFile._open(self)
Expand Down
6 changes: 3 additions & 3 deletions PIL/TiffTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def lookup(tag):
342: ("TransferRange", SHORT, 6),

347: ("JPEGTables", UNDEFINED, 1),

# obsolete JPEG tags
512: ("JPEGProc", SHORT, 1),
513: ("JPEGInterchangeFormat", LONG, 1),
Expand All @@ -161,7 +161,7 @@ def lookup(tag):
532: ("ReferenceBlackWhite", LONG, 0),

700: ('XMP', BYTE, 1),

33432: ("Copyright", ASCII, 1),
34377: ('PhotoshopInfo', BYTE, 1),

Expand Down Expand Up @@ -193,7 +193,7 @@ def lookup(tag):

50741: ("MakerNoteSafety", SHORT, 1, {"Unsafe": 0, "Safe": 1}),
50780: ("BestQualityScale", RATIONAL, 1),
50838: ("ImageJMetaDataByteCounts", LONG, 0), # Can be more than one
50838: ("ImageJMetaDataByteCounts", LONG, 0), # Can be more than one
50839: ("ImageJMetaData", UNDEFINED, 1) # see Issue #2006
}

Expand Down
1 change: 0 additions & 1 deletion PIL/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ def get_supported():
ret.extend(get_supported_features())
ret.extend(get_supported_codecs())
return ret

3 changes: 0 additions & 3 deletions Tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@ To run an individual test::
Run all the tests from the root of the Pillow source distribution::

./test-installed.py



8 changes: 4 additions & 4 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def assert_image_equal(self, a, b, msg=None):
logger.error("Url for test images: %s" %url)
except:
pass

self.fail(msg or "got different content")

def assert_image_similar(self, a, b, epsilon, msg=None):
Expand Down Expand Up @@ -206,15 +206,15 @@ class PillowLeakTestCase(PillowTestCase):
# requires unix/osx
iterations = 100 # count
mem_limit = 512 # k

def _get_mem_usage(self):
"""
Gets the RUSAGE memory usage, returns in K. Encapsulates the difference
between OSX and Linux rss reporting

:returns; memory usage in kilobytes
"""

from resource import getpagesize, getrusage, RUSAGE_SELF
mem = getrusage(RUSAGE_SELF).ru_maxrss
if sys.platform == 'darwin':
Expand All @@ -225,7 +225,7 @@ def _get_mem_usage(self):
# linux
# man 2 getrusage
# ru_maxrss (since Linux 2.6.32)
# This is the maximum resident set size used (in kilobytes).
# This is the maximum resident set size used (in kilobytes).
return mem # Kb

def _test_leak(self, core):
Expand Down
1 change: 0 additions & 1 deletion Tests/icc/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ and that the name of ICC shall not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission. ICC makes no representations about the suitability
of this software for any purpose.

2 changes: 1 addition & 1 deletion Tests/test_file_sgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_write16(self):

reloaded = Image.open(out)
self.assert_image_equal(im, reloaded)

def test_unsupported_mode(self):
im = hopper('LA')
out = self.tempfile('temp.sgi')
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_tiff_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_rt_metadata(self):
self.assertAlmostEqual(loaded_double, doubledata)

# check with 2 element ImageJMetaDataByteCounts, issue #2006

info[ImageJMetaDataByteCounts] = (8, len(bindata) - 8)
img.save(f, tiffinfo=info)
loaded = Image.open(f)
Expand Down
4 changes: 2 additions & 2 deletions Tests/test_font_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _test_font(self, font):
draw = ImageDraw.ImageDraw(im)
self._test_leak(lambda: draw.text((0, 0), "some text "*1024, #~10k
font=font, fill="black"))

@unittest.skipIf(not features.check('freetype2'), "Test requires freetype2")
def test_leak(self):
ttype = ImageFont.truetype('Tests/fonts/FreeMono.ttf', 20)
Expand All @@ -24,7 +24,7 @@ class TestDefaultFontLeak(TestTTypeFontLeak):
# fails at iteration 37 in master
iterations = 100
mem_limit = 1024 #k

def test_leak(self):
default_font = ImageFont.load_default()
self._test_font(default_font)
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_font_pcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_draw(self):
draw.text((0, 0), message, 'black', font=font)
with Image.open('Tests/images/test_draw_pbm_target.png') as target:
self.assert_image_similar(im, target, 0)

def test_textsize(self):
tempname = self.save_font()
font = ImageFont.load(tempname)
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_image_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def test_embeddable(self):

compiler = ccompiler.new_compiler()
compiler.add_include_dir(sysconfig.get_python_inc())

libdir = sysconfig.get_config_var('LIBDIR') or sysconfig.get_python_inc().replace('include', 'libs')
print (libdir)
compiler.add_library_dir(libdir)
Expand All @@ -302,10 +302,10 @@ def test_embeddable(self):

env = os.environ.copy()
env["PATH"] = sys.prefix + ';' + env["PATH"]

# do not display the Windows Error Reporting dialog
ctypes.windll.kernel32.SetErrorMode(0x0002)

process = subprocess.Popen(['embed_pil.exe'], env=env)
process.communicate()
self.assertEqual(process.returncode, 0)
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_image_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_trns_p_rgba(self):
self.assertNotIn('transparency', rgba.info)
# https://github.com/python-pillow/Pillow/issues/2702
self.assertEqual(rgba.palette, None)


def test_trns_l(self):
im = hopper('L')
Expand Down
4 changes: 2 additions & 2 deletions Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,10 @@ def test_render_empty(self):
im = Image.new(mode='RGB', size=(300, 100))
target = im.copy()
draw = ImageDraw.Draw(im)
#should not crash here.
#should not crash here.
draw.text((10, 10), '', font=font)
self.assert_image_equal(im, target)

def test_unicode_pilfont(self):
# should not segfault, should return UnicodeDecodeError
# issue #2826
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_imagefontctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def test_english(self):
im = Image.new(mode='RGB', size=(300, 100))
draw = ImageDraw.Draw(im)
draw.text((0, 0), 'TEST', font=ttf, fill=500, direction='ltr')


def test_complex_text(self):
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)

Expand Down Expand Up @@ -102,7 +102,7 @@ def test_ligature_features(self):

liga_size = ttf.getsize('fi', features=['-liga'])
self.assertEqual(liga_size,(13,19))

def test_kerning_features(self):
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_lib_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_L(self):
self.assert_unpack("L", "L;R", 1, 128, 64, 192, 32)
self.assert_unpack("L", "L;16", 2, 2, 4, 6, 8)
self.assert_unpack("L", "L;16B", 2, 1, 3, 5, 7)
self.assert_unpack("L", "L;16", b'\x00\xc6\x00\xaf', 198, 175)
self.assert_unpack("L", "L;16", b'\x00\xc6\x00\xaf', 198, 175)
self.assert_unpack("L", "L;16B", b'\xc6\x00\xaf\x00', 198, 175)


Expand Down
21 changes: 10 additions & 11 deletions _imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,11 +1499,11 @@ _resize(ImagingObject* self, PyObject* args)
int xsize, ysize;
int filter = IMAGING_TRANSFORM_NEAREST;
float box[4] = {0, 0, 0, 0};

imIn = self->image;
box[2] = imIn->xsize;
box[3] = imIn->ysize;

if (!PyArg_ParseTuple(args, "(ii)|i(ffff)", &xsize, &ysize, &filter,
&box[0], &box[1], &box[2], &box[3]))
return NULL;
Expand Down Expand Up @@ -3345,7 +3345,7 @@ _reset_stats(PyObject* self, PyObject* args)

if (!PyArg_ParseTuple(args, ":reset_stats"))
return NULL;

arena->stats_new_count = 0;
arena->stats_allocated_blocks = 0;
arena->stats_reused_blocks = 0;
Expand All @@ -3361,7 +3361,7 @@ _get_alignment(PyObject* self, PyObject* args)
{
if (!PyArg_ParseTuple(args, ":get_alignment"))
return NULL;

return PyInt_FromLong(ImagingDefaultArena.alignment);
}

Expand All @@ -3370,7 +3370,7 @@ _get_block_size(PyObject* self, PyObject* args)
{
if (!PyArg_ParseTuple(args, ":get_block_size"))
return NULL;

return PyInt_FromLong(ImagingDefaultArena.block_size);
}

Expand All @@ -3379,7 +3379,7 @@ _get_blocks_max(PyObject* self, PyObject* args)
{
if (!PyArg_ParseTuple(args, ":get_blocks_max"))
return NULL;

return PyInt_FromLong(ImagingDefaultArena.blocks_max);
}

Expand All @@ -3389,7 +3389,7 @@ _set_alignment(PyObject* self, PyObject* args)
int alignment;
if (!PyArg_ParseTuple(args, "i:set_alignment", &alignment))
return NULL;

if (alignment < 1 || alignment > 128) {
PyErr_SetString(PyExc_ValueError, "alignment should be from 1 to 128");
return NULL;
Expand All @@ -3412,7 +3412,7 @@ _set_block_size(PyObject* self, PyObject* args)
int block_size;
if (!PyArg_ParseTuple(args, "i:set_block_size", &block_size))
return NULL;

if (block_size <= 0) {
PyErr_SetString(PyExc_ValueError,
"block_size should be greater than 0");
Expand All @@ -3437,7 +3437,7 @@ _set_blocks_max(PyObject* self, PyObject* args)
int blocks_max;
if (!PyArg_ParseTuple(args, "i:set_blocks_max", &blocks_max))
return NULL;

if (blocks_max < 0) {
PyErr_SetString(PyExc_ValueError,
"blocks_max should be greater than 0");
Expand All @@ -3460,7 +3460,7 @@ _clear_cache(PyObject* self, PyObject* args)

if (!PyArg_ParseTuple(args, "|i:clear_cache", &i))
return NULL;

ImagingMemoryClearCache(&ImagingDefaultArena, i);

Py_INCREF(Py_None);
Expand Down Expand Up @@ -3718,4 +3718,3 @@ init_imaging(void)
setup_module(m);
}
#endif

5 changes: 2 additions & 3 deletions _imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
return NULL;
}

if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|is"PY_ARG_BYTES_LENGTH"i",
if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|is"PY_ARG_BYTES_LENGTH"i",
kwlist,
Py_FileSystemDefaultEncoding, &filename,
&size, &index, &encoding, &font_bytes,
Expand Down Expand Up @@ -513,7 +513,7 @@ font_getsize(FontObject* self, PyObject* args)
PyMem_Free(glyph_info);
glyph_info = NULL;
}

if (face) {

/* left bearing */
Expand Down Expand Up @@ -891,4 +891,3 @@ init_imagingft(void)
setup_module(m);
}
#endif

1 change: 0 additions & 1 deletion _imagingmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,3 @@ init_imagingmath(void)
setup_module(m);
}
#endif

1 change: 0 additions & 1 deletion _imagingmorph.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,3 @@ init_imagingmorph(void)
setup_module(m);
}
#endif

1 change: 0 additions & 1 deletion _imagingtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ init_imagingtk(void)
load_tkinter_funcs();
}
#endif

1 change: 0 additions & 1 deletion decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,4 +942,3 @@ PyImaging_Jpeg2KDecoderNew(PyObject* self, PyObject* args)
return (PyObject*) decoder;
}
#endif /* HAVE_OPENJPEG */

Loading