Commit Graph

13701 Commits

Author SHA1 Message Date
Brian Crowell
3a665a7835 py3k: Add true Unicode support to OleFileIO
The day has arrived when Python provides an official way to handle Unicode
strings.
2013-01-10 08:46:44 -06:00
Brian Crowell
fc035814bd py3k: map and filter to list comprehensions
What's really going on is that map() and filter() return iterators in py3k.
I've just gone ahead and turned them all into list comprehensions, because
I find them much easier to read.
2013-01-10 08:46:43 -06:00
Brian Crowell
e514912378 py3k: Rewrite dictionary support for Tiff ImageFileDictionary
This commit brings in the collections.MutableMapping mixin to provide full
dictionary support for ImageFileDictionary.
2013-01-10 08:46:43 -06:00
Brian Crowell
09f1081c95 py3k: Fix up uses of dictionary views, ranges, and has_key()
y.has_key(x) is gone (use x in y), and keys(), values(), items(), and
range() all return views.

Some iterables needed to be packed into lists, either because the code
expected a list (such as "range(256) * 3") or because the original
collection was being modified (automatic global declarations).

The Tiff ImageFileDictionary is a special case and will be dealt with in
another commit.
2013-01-10 08:46:42 -06:00
Brian Crowell
b386ed14dd py3k: Remove callable() function
callable(c) is isinstance(x, collections.Callable) in py3k.
2013-01-10 08:46:41 -06:00
Brian Crowell
718dbcc8ca py3k: Provide the missing pngtest_bad.png.base64
This is from http://scary.beasts.org/security/CESA-2004-001.txt. This was
missing from Gohlke's tests. With this file, I see 79 tests and no failures
on my setup from 2.6/2.7.
2013-01-10 08:46:41 -06:00
Brian Crowell
c8ce29c239 FIX: Handle long values in _imaging getink
This gets the putdata test case to run correctly under 2.6/2.7. It fixes an
issue where the value 0xFFFFFFFF (which is long in old Python) isn't
recognized and putdata tries to parse it as a tuple.

The original fix comes from Christoph Gohlke. It was adapted to work in
both 2.* and 3.*.
2013-01-10 08:46:40 -06:00
Brian Crowell
197885164b py3k: Backport Gohlke's tests to run on 2.6/2.7
Most of the differences are in tobytes/tostring naming and expected
behavior of the bytes() constructor. The latter was usually easy to fix
with the right bytes literal.

This is a good preview of what will have to happen in the Python 3 code.
2013-01-10 08:46:39 -06:00
Brian Crowell
ad784eb808 py3k: Import Christoph Gohlke's test suite
This is Christoph Gohlke's test suite from his personal PIL package found
at http://www.lfd.uci.edu/~gohlke/pythonlibs/.

This is just to bring it in as a separate commit. Future commits will align
it with Pillow.
2013-01-10 08:46:39 -06:00
Brian Crowell
9631d42b60 py3k: Use "y#" code in PyArg_ParseTuple where we expect byte data
This commit also renames some functions from "fromstring" and the like to
"frombytes". I'll probably need to come back later and update any
references to "string," here or in the docs.

I also noticed that encode allocates some data for certain codecs, but
never frees them. That would be a good bug to fix. I fixed the one where it
outright stole a pointer from Python.
2013-01-10 08:46:38 -06:00
Brian Crowell
4459715b6e py3k: Fix strict aliasing warnings under Python 3 2013-01-10 08:46:37 -06:00
Brian Crowell
af5228896a py3k: Add module initialization and unicode/bytes int/long thunks
This commit:

* Adds Python 3 module initialization functions. I split out the main init
  of each module into a static setup_module function.
* Adds a py3.h which unifies int/long in Python 3 and unicode/bytes in
  Python 2. _imagingft.c unfortunately looks a little kludgy after this
  because it was already using PyUnicode functions, and I had to mix and
  match there manually.

With this commit, the modules all build successfully under Python 3.

What this commit does NOT do is patch all of the uses of PyArg_ParseTuple
and Py_BuildValue, which all need to be checked for proper use of bytes
and unicode codes. It also does not let selftest.py run yet, because there
are probably hundreds of issues to fix in the Python code itself.
2013-01-10 08:46:37 -06:00
Brian Crowell
89e82c5888 py3k: Fix strict aliasing slip-up in _imaging
Python 3 enables C's strict aliasing rules for the first time, which means
you need to be careful about the ways you reference pointers. Here, we're
using a char[4] as an INT32, so we cast between them using a union.
2013-01-10 08:46:36 -06:00
Brian Crowell
d28a2fee76 py3k: Remove HAVE_UNICODE from _imagingft
I'm pretty sure this preserves the intent of the code. HAVE_UNICODE is now
assumed, and PyString is only used if we're not in Py3k.

Since this is the only file that uses PyUnicode, I'm going to go ahead and
#define PyUnicode and PyBytes back to PyString for 2.6, and explicitly
change out every call so I have to check them all.
2013-01-10 08:46:36 -06:00
Brian Crowell
804095ecb3 py3k: Use new buffer protocol
Other ports have taken advantage of the fact that Python 3 has wrappers for
the old buffer protocol, but there's a significant disadvantage: you can't
let the buffered object know when you're done with it.

Since Python 2.6 supports the new protocol, we just go ahead and move to
it.
2013-01-10 08:46:35 -06:00
Brian Crowell
9519013466 py3k: Modernize type declarations
This updates several Python type definitions and uses to bring us closer
to Python 3 compatibility. This includes:

* Replacing staticforward and statichere with static. These were a hack for
  old compilers and are not supported/needed anymore.
* Using Py_TYPE() instead of ob_type; ob_type is hidden in Py3.
* Replacing getattr with getters/setters. getattr is sort-of supported in
  Py3, but Py_FindMethod is not. So we just use the newer
  methods/getsetters mechanisms and start using PyType_Ready everywhere.
* Use PyVarObject_HEAD_INIT for types, since types are PyVarObject.
* Use PyMODINIT_FUNC for module initialization functions.

There are some tab/space issues in this commit. I'm set for spaces; the
source is a little schizo.
2013-01-10 08:46:34 -06:00
Brian Crowell
009eee0577 py3k: Get setup.py to run under python3
First real fix: open the temp file in text mode.
2013-01-10 08:46:34 -06:00
Brian Crowell
78575798d7 py3k: Update exception usage to modern syntax 2013-01-10 08:46:33 -06:00
Brian Crowell
37f22ebfcd py3k: Use string methods instead of string module
First, we go for the obvious stuff. The string module methods are gone in
3.0, so we translate them to the appropriate methods on the string class.
2013-01-10 08:42:49 -06:00
Alex Clark ☺
eaf27c93bd Merge pull request #33 from d-schmidt/bugfix
fixed crash loading broken color profile from file-like object
2013-01-10 04:45:50 -08:00
d-schmidt
a36338f195 fixed crash loading broken color profile from file-like object 2013-01-09 21:04:02 +01:00
Alex Clark ☺
a8304648af Merge pull request #32 from lynx-r/master
Move custom path of JPEG_ROOT, TIFF_ROOT, etc. before system.
2013-01-09 04:17:44 -08:00
Alex Po
8b14c9721a Move custom path of JPEG_ROOT, TIFF_ROOT, etc. before system. 2013-01-09 15:48:06 +04:00
Alex Clark ☺
d4c30b7171 Merge pull request #29 from twpayne/alpha-composite-rounding
Avoid rounding error in Image.alpha_composite
2013-01-09 03:30:15 -08:00
Alex Clark ☺
88a7672163 Merge pull request #31 from cgohlke/patch-1
Make FLI image detection more stringent
2013-01-09 03:14:39 -08:00
cgohlke
11a859e7d3 Make FLI image detection more stringent 2012-12-20 21:47:45 -08:00
Tom Payne
9d35947363 Avoid rounding error in Image.alpha_composite 2012-12-19 14:25:22 +01:00
Alex Clark ☺
0b06bdcb2f Merge pull request #24 from maebert/patch-1
Radius was hardcoded to 2.
2012-12-06 16:26:06 -08:00
Alex Clark ☺
7c3431663f Merge pull request #19 from fluggo/upstream
Add files to the MANIFEST which were missing from the source distribution
2012-12-06 16:24:05 -08:00
Manuel Ebert
4e397a4d1c Radius was hardcoded to 2.
This will probably, some time in the future get fixed upstream in PIL. Maybe.
2012-12-06 16:19:55 -08:00
Alex Clark ☺
6bd4c34317 Merge pull request #23 from twpayne/alpha-composite
Add Image.alpha_composite
2012-12-06 07:18:14 -08:00
Tom Payne
e414c66070 Add Image.alpha_composite 2012-12-04 16:44:26 +01:00
Brian J. Crowell
706f1e33c3 Add files to the MANIFEST which were missing from the source distribution 2012-11-10 11:26:37 -06:00
Alex Clark
4a10a363e4 Release 1.7.8 2012-11-01 17:09:46 -04:00
Alex Clark
5ab5406010 Fix formatting of installation summary 2012-11-01 17:08:29 -04:00
Alex Clark ☺
449a5395ee Merge pull request #13 from tdesvenain/master
Removed doctests.py that made tests of other packages fail.
2012-11-01 13:41:58 -07:00
tdesvenain
c5097fb1d2 Removed doctests.py that made tests of other packages fail. 2012-09-21 14:15:54 +02:00
Alex Clark ☺
eec9c41041 Merge pull request #5 from tdesvenain/master
More psd files handled
2012-09-07 18:58:53 -07:00
Alex Clark ☺
7e7e1ab926 Merge pull request #11 from larsyencken/master
Fix a bug in quantize() causing crashes.
2012-09-07 18:56:55 -07:00
Lars Yencken
155347fe87 Fix a bug in quantize() causing PIL crashes.
From German Bravo's Image-SIG post:
http://mail.python.org/pipermail/image-sig/2012-June/007047.html
2012-09-05 13:23:57 +10:00
Alex Clark
7c4437f64b Fix URL 2012-08-22 16:47:36 -04:00
tdesvenain
3eda40cb4c revert last commit, images rendered didn't match very well 2012-07-29 17:05:54 +02:00
tdesvenain
bc9455d059 Added a psd mode (mode 4, 16 bits). 2012-07-29 16:02:26 +02:00
tdesvenain
4ebe7fc459 Fix opening psd files with RGBA layers when A mode is not of type 65535
but 3.
Fixes issue https://github.com/python-imaging/Pillow/issues/3
2012-07-29 15:48:40 +02:00
Alex Clark
f5caa40711 Save issues and comments 2012-07-24 18:04:07 -04:00
Alex Clark
c3bee2cd13 Save watchers 2012-07-24 17:55:18 -04:00
Alex Clark
f26c5fc16d Change URL 2012-07-24 17:44:21 -04:00
Alex Clark
1dca68b38c Test travis 2012-07-11 12:17:29 -04:00
Alex Clark
a4f0521eec Test travis 2012-07-11 12:15:27 -04:00
Alex Clark
3f348ab1a0 Merge pull request #26 from cmr/master
better import of _imaging
2012-06-15 13:52:38 -07:00