Commit Graph

196 Commits

Author SHA1 Message Date
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
Andrew Murray
fab0205abc Updated documentation [ci skip] 2019-10-08 21:12:15 +11:00
Hugo
f0a87e25a4 Drop support for EOL PyQt4 and PySide 2019-09-30 17:58:31 +03:00
Hugo van Kemenade
310d2c9005
Add option to capture all monitors on Windows (#3950)
Add option to capture all monitors on Windows
2019-09-27 08:47:55 +03:00
nulano
3c311f5619 add version added [ci skip] 2019-09-27 00:58:32 +02:00
nulano
6a2d8f8da0 rename parameter, add note to docs 2019-09-20 17:35:08 +02:00
Hugo
f792ab6c02 RST uses double backticks for code (MD uses 1) 2019-09-13 08:56:33 +03:00
Andrew Murray
da39d40342
Merge pull request #3978 from radarhere/stroke
Added text stroking
2019-09-06 19:14:49 +10:00
nulano
fa6b80fddf add option to capture all monitors on Windows 2019-08-15 20:03:33 +10:00
Andrew Murray
4283683948 Corrected note syntax [ci skip] 2019-08-03 23:24:28 +10:00
Andrew Murray
f93a5d0972 Added text stroking 2019-07-29 06:40:03 +10:00
Andrew Murray
dfed1424d1 Improved ImageFont documentation 2019-07-25 20:04:45 +10:00
Jon Dufresne
8fac23b3df Clean up several Sphinx warnings
Appeared as:

    Pillow/docs/reference/ImageDraw.rst:137: WARNING: Unexpected indentation.
    Pillow/docs/reference/ImageDraw.rst:164: WARNING: Unexpected indentation.
    Pillow/docs/reference/ImageDraw.rst:177: WARNING: Unexpected indentation.
    Pillow/docs/reference/ImageDraw.rst:208: WARNING: Unexpected indentation.
    Pillow/docs/reference/ImageStat.rst:24: WARNING: Explicit markup ends without a blank line; unexpected unindent.
2019-07-06 17:12:09 -07:00
Hugo
a0191dae1e
Documentation for Image module (#3776)
Documentation for Image module
2019-06-28 19:49:45 +03:00
Hugo
57e3af4afb Fix typo 2019-06-28 18:47:17 +03:00
Hugo
73884576d4 Some styling and wording 2019-06-24 11:04:13 +03:00
Hugo
72bf9f6529 Use the common test-suite image 2019-06-24 10:48:33 +03:00
Hugo
fd1d779ae1 Strip trailing whitespace 2019-06-24 10:45:53 +03:00
Hugo
169961649d
Merge pull request #3848 from radarhere/pa
Improved palette handling for LA and PA modes
2019-06-05 22:32:44 +03:00
Andrew Murray
8be6609243 Added PA mode to docs [ci skip] 2019-05-18 20:41:59 +10:00
Andrew Murray
110dd6236f Highlight function [ci skip] 2019-05-08 12:54:12 +10:00
Hugo
82d9ea5eac
Merge pull request #3808 from radarhere/imagegrab
Added option to include layered windows in ImageGrab.grab on Windows
2019-05-04 16:00:43 +03:00
Hugo
c15dc4d7ca
Document format limitations of ImageStat.Stat.extrema (#3661)
Document format limitations of ImageStat.Stat.extrema
2019-05-03 22:14:14 +03:00
Andrew Murray
70038bd71e Added option to include layered windows in ImageGrab.grab on Windows 2019-04-26 20:09:46 +10:00
Andrew Murray
31340bb3c6 Corrected names in documentation 2019-04-24 06:19:17 +10:00
Andrew Murray
0557ecbb3e Document class members automatically 2019-04-21 23:28:08 +10:00
Andrew Murray
93b96a6cb8 Improved documentation 2019-04-21 23:27:31 +10:00
abojja9
c4daa87415 Add documentation to Image module 2019-04-06 13:42:22 -07:00
Andrew Murray
7fd0a1493a Changed wording [ci skip] 2019-03-31 14:36:39 +11:00
Hugo
90886b1888
Merge branch 'master' into imagecms-deprecations 2019-03-27 12:03:54 +02:00
Hugo
30841fe808
Merge pull request #3737 from jdufresne/quotes
Add backticks around Python classes and modules in open_files.rst
2019-03-23 08:31:15 +00:00
Jon Dufresne
d31bee5e35 Add backticks around Python classes and modules in open_files.rst 2019-03-22 06:12:08 -07:00
Jon Dufresne
deb8a7aadd Remove additional references to removed handles_eof
handles_eof was removed in 90760a5f30.
2019-03-22 05:58:22 -07:00
Ben Yang
8bd4bbb808 implemented language parameter for multiline ImageDraw methods, updated release notes 2019-03-11 20:21:52 -07:00
Ben Yang
515244b672 moved language parameter in ImageDraw documentation 2019-03-11 18:56:22 -07:00
Ben Yang
c6ad867178 added proper documentation for ImageFont.getsize() 2019-03-11 18:56:22 -07:00
Ben Yang
d5bbf01254 moved 'language' parameter to last parameter in relevant functions 2019-03-11 18:56:22 -07:00
Ben Yang
8624efd283 added ability to set language for text rendering 2019-03-11 18:55:46 -07:00
Hugo
6f24eda48a Document format limitations of ImageStat.Stat.extrema and recommend more efficient Image.getextrema 2019-03-06 17:49:25 +02:00
Andrew Murray
7477036230
Merge branch 'master' into imagecms-deprecations 2019-02-21 20:00:27 +11:00
Hugo
186f7d943b Document deprecation 2019-02-14 23:44:07 +02:00
Hugo
3ff70c2afc
Merge branch 'master' into imagecms-deprecations 2019-02-13 15:45:28 +02:00
Andrew Murray
4fe63e44d7 Fixed typo [ci skip] 2019-02-10 12:33:16 +11:00
Hugo
7d157bd825 Add warnings to deprecated CMS profile attributes 2019-01-28 15:40:19 +02:00
Andrew Murray
32c344b7ce Added note about ImageDraw operations that exceed image bounds [ci skip] 2019-01-27 22:10:54 +11:00
Hugo
398d2f0c15
Merge pull request #3522 from radarhere/imagechops
Improved ImageChops documentation
2019-01-01 12:21:28 +02:00
Andrew Murray
fc354cabaa Added method 2019-01-01 14:11:52 +11:00
Andrew Murray
671f7a392d Allow RGBA value for P image putpixel 2018-12-31 13:37:04 +11:00
Andrew Murray
3f6282e259 Allow RGB value for P image putpixel 2018-12-31 11:35:15 +11:00
Andrew Murray
b0330047ff Minor edit 2018-12-12 00:53:31 +11:00