Commit Graph

102 Commits

Author SHA1 Message Date
Aarni Koskela
8ca53b312d Enforce CSV parametrize names style 2024-08-07 12:27:20 +03:00
Hugo van Kemenade
51bd7d2ea8
Drop support for Python 3.8 (#8183)
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2024-07-03 00:44:45 -06:00
Hugo van Kemenade
2a660bbe9f Remove PSFile class, deprecated in Pillow 9.5.0 2024-07-01 10:58:27 +03:00
Andrew Murray
b17f1e507b Use f-strings 2024-05-07 14:01:08 +10:00
Andrew Murray
54d329b192 Merge branch 'main' into import 2024-03-12 12:01:50 +11:00
Hugo van Kemenade
9ad22fc96a
Merge pull request #7753 from radarhere/eps 2024-03-11 17:51:29 +02:00
Andrew Murray
cdc498e6f3 Added type hints 2024-02-07 19:16:28 +11:00
Hugo van Kemenade
4a4b90c365
Autotype tests (#7756)
* autotyping: --none-return
* autotyping: --scalar-return
* autotyping: --int-param
* autotyping: --float-param
* autotyping: --str-param
* autotyping: --annotate-named-param tmp_path:pathlib.Path
2024-01-31 20:12:58 +11:00
Andrew Murray
5721577e4e Stop reading EPS at EOF marker 2024-01-25 20:20:53 +11:00
Hugo van Kemenade
53c3cd9f8e isort Tests 2024-01-20 13:23:03 +02:00
Andrew Murray
2d6ad5868d Use "non-zero" consistently 2024-01-06 12:07:55 +11:00
Andrew Murray
f6f3dab672 Import UnidentifiedImageError directly 2023-12-27 17:42:17 +11:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Hugo van Kemenade
0a432541ae
Merge pull request #7392 from radarhere/eps 2023-10-05 09:27:06 -06:00
Andrew Murray
094f23dd5c EOF ends not just the trailer, but also the file 2023-09-22 18:26:41 +10:00
Andrew Murray
a84a43528e Added gs_binary to control Ghostscript use on all platforms 2023-09-12 19:46:46 +10:00
nopperl
69b888e53d
remove test parameterization
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2023-09-11 20:35:13 +00:00
pre-commit-ci[bot]
794a1d7ff2 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-09-07 18:36:32 +00:00
nopperl
12d8b439d5 Read bounding box information from the trailer of EPS files if specified 2023-09-07 20:20:35 +02:00
Yay295
dd985b2a5e make deprecation check more specific 2023-02-07 13:58:05 -06:00
Yay295
bd0fac80c4 deprecate EpsImagePlugin.PSFile 2023-02-06 17:26:05 -06:00
Yay295
be9aea35a8 add eps test for bad BoundingBox, good ImageData 2023-02-06 17:26:04 -06:00
Yay295
3d6770d0f3 add tests for long lines 2023-01-15 15:56:49 -06:00
Yay295
4c2550db42 add test for invalid bounding box 2023-01-15 15:56:49 -06:00
Yay295
0334e68f95 add more eps file tests 2023-01-12 08:46:03 -06:00
Yay295
c3134dc049 refactor EpsImagePlugin
Merge the PSFile class into the EpsImageFile class to hopefully improve performance.
Also added a check for the required "%!PS-Adobe" and "%%BoundingBox" header comments.
2023-01-10 08:44:38 -06:00
Andrew Murray
c259ac492f Parametrized tests 2022-10-03 16:57:42 +11:00
Andrew Murray
985fec2f56 Removed duplicate test 2022-10-03 16:54:46 +11:00
Andrew Murray
7e1a0ca544 Open 1 bit EPS in mode 1 2022-08-13 18:32:29 +10:00
Andrew Murray
fb7edfda68 Improved consistency of returning an image access object from load() 2022-02-02 11:49:31 +11:00
Andrew Murray
1d73a483f4 Added "transparency" argument to load() 2021-07-19 09:08:45 +10:00
Eric Soroos
1c872a9eda lint stuff 2021-04-10 16:58:01 +02:00
Eric Soroos
a3a69c8385 conditional mark for valgrind ignore 2021-04-09 23:53:24 +02:00
Hugo van Kemenade
8febdad8dd Review, typos and lint 2021-04-01 17:41:46 +03:00
Eric Soroos
5a5e6db0ab Fix EPS DOS on _open -- CVE-2021-28677
* The readline used in EPS has to deal with any combination of \r and
  \n as line endings. It used an accidentally quadratic method of
  accumulating lines while looking for a line ending.
* A malicious EPS file could use this to perform a DOS of Pillow in
  the open phase, before an image was accepted for opening.
* This dates to the PIL Fork
2021-04-01 17:17:18 +03:00
Andrew Murray
3495b319bd Replaced various instances of assert_image_similar with assert_image_similar_tofile 2021-02-21 22:22:29 +11:00
Eric Soroos
a6fa139f62 useless reptile 2021-01-07 14:57:49 +01:00
Eric Soroos
1d7c8e03d0 known failing tests from valgrind -- uninitialized values 2021-01-07 14:52:02 +01:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Hugo van Kemenade
12f66f44f4
Fix regression
Co-Authored-By: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2020-02-23 10:31:54 +02:00
Hugo
44e661f25a Convert to use pytest 2020-02-22 23:03:01 +02:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Jon Dufresne
4f185329f4 Streamline test skipping based on supported features
This adds a new test decorator: skip_unless_feature(). The argument is
the same as passed to features.check(). If the feature is not supported,
the test will be skipped.

This removes several kinds of boilerplate copied and pasted around tests
so test feature checking is handled and displayed more consistently.

Refs #4193
2020-02-18 13:07:01 -08:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11:00
Jon Dufresne
33dabf986f Import unittest from stdlib rather than helper.py
The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d so import from the more
typical stdlib location.
2019-11-20 18:42:52 -08:00
Hugo
cc63f66575 Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
Jon Dufresne
4cd4adddc3 Improve handling of file resources
Follow Python's file object semantics. User code is responsible for
closing resources (usually through a context manager) in a deterministic
way.

To achieve this, remove __del__ functions. These functions used to
closed open file handlers in an attempt to silence Python
ResourceWarnings. However, using __del__ has the following drawbacks:

- __del__ isn't called until the object's reference count reaches 0.
  Therefore, resource handlers remain open or in use longer than
  necessary.

- The __del__ method isn't guaranteed to execute on system exit. See the
  Python documentation:

  https://docs.python.org/3/reference/datamodel.html#object.__del__

  > It is not guaranteed that __del__() methods are called for objects
  > that still exist when the interpreter exits.

- Exceptions that occur inside __del__ are ignored instead of raised.
  This has the potential of hiding bugs. This is also in the Python
  documentation:

  > Warning: Due to the precarious circumstances under which __del__()
  > methods are invoked, exceptions that occur during their execution
  > are ignored, and a warning is printed to sys.stderr instead.

Instead, always close resource handlers when they are no longer in use.
This will close the file handler at a specified point in the user's code
and not wait until the interpreter chooses to. It is always guaranteed
to run. And, if an exception occurs while closing the file handler, the
bug will not be ignored.

Now, when code receives a ResourceWarning, it will highlight an area
that is mishandling resources. It should not simply be silenced, but
fixed by closing resources with a context manager.

All warnings that were emitted during tests have been cleaned up. To
enable warnings, I passed the `-Wa` CLI option to Python. This exposed
some mishandling of resources in ImageFile.__init__() and
SpiderImagePlugin.loadImageSeries(), they too were fixed.
2019-10-12 08:27:17 -07:00
Hugo
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
Jon Dufresne
d50445ff30 Introduce isort to automate import ordering and formatting
Similar to the recent adoption of Black. isort is a Python utility to
sort imports alphabetically and automatically separate into sections. By
using isort, contributors can quickly and automatically conform to the
projects style without thinking. Just let the tool do it.

Uses the configuration recommended by the Black to avoid conflicts of
style.

Rewrite TestImageQt.test_deprecated to no rely on import order.
2019-07-06 16:11:35 -07:00