Commit Graph

180 Commits

Author SHA1 Message Date
Bryant Mairs
d5d66db9de Modified map.c to fix some MSVC10 compilation errors. 2013-01-10 08:37:38 -06:00
Brian J. Crowell
121f7bc013 Handle Sane option strings as Unicode strings
The Sane documentation seems to imply that these option strings contain
Latin-1 text, not byte data, so we decode it and present it to the user
that way.
2013-01-09 23:46:45 -06:00
Brian J. Crowell
5e935b8ee2 Set up Sane error object as exception instead of string
String exceptions don't work anymore.
2013-01-09 23:45:17 -06:00
Sandro Mani
085ca82e8c Make pysane Python3-compatible 2013-01-09 22:22:58 -06:00
Brian J. Crowell
59510d46c6 Update the manifest to include a lot of missing files 2012-11-10 11:01:14 -06:00
Mikhail Korobov
5dd80825b4 Fix tox test running: port selftest.py to Python 3; make it clear Python 2.5 is no longer supported (its support is broken in many ways in this branch); remove bundled doctest.py module (it is in stdlib since forever); remove extra stuff from tox.ini 2012-11-08 23:40:44 -06:00
Mikhail Korobov
fcd6903151 fix packaging: py3.h must be included in distribution (tox tests didn't run without this) 2012-11-08 23:40:44 -06:00
Brian J. Crowell
3ff0f667c4 py3k: Issue warnings when using the old fromstring/tostring
...although, you have to turn on deprecation warnings specifically in order
to get them.
2012-11-08 23:40:44 -06:00
Brian J. Crowell
4245aff813 py3k: inquiry is now lenfunc
This fixes a build warning on 64-bit machines.
2012-11-08 23:40:44 -06:00
Brian Crowell
d094136171 py3k: Remove use_2to3 from setup.py
This is unnecessary now.
2012-11-08 23:40:44 -06:00
Brian Crowell
4a79a398d3 py3k: Add Windows icon sanity test 2012-11-08 23:40:44 -06:00
Brian Crowell
da0c0274fa py3k: Add XPM read test
This test includes an XPM file with transparency.
2012-11-08 23:40:44 -06:00
Brian Crowell
9d22daf213 py3k: Add TarIO test
Not too convinced of the size fix. While it works against my file, I'm not
sure someone would have accidentally been an index off and not noticed.
2012-11-08 23:40:44 -06:00
Brian Crowell
b555813c92 py3k: Rewrite PdfImagePlugin into something more legible
After adding all the encode() calls, the PDF plugin (and a few others)
became much harder to read. This should be much easier on the eyes.
2012-11-08 23:40:44 -06:00
Brian Crowell
569136fbdb py3k: Add .FLI sanity check, and fix palette bytes bug 2012-11-08 23:40:44 -06:00
Brian Crowell
bda1831d73 py3k: Add Photoshop sanity check 2012-11-08 23:40:44 -06:00
Brian Crowell
8b3acd6961 py3k: Add PCX to roundtrip test
For some reason, the PCX codec round-trips now.
2012-11-08 23:40:44 -06:00
Brian Crowell
b05745ab05 py3k: Actually fix the EPS encoder
The EPS encoder wasn't part of Gohlke's test suite, so the previous "fixes"
there were only expected syntactic ones. This gives a cleaner fix to the
encoder.

The decoder doesn't work in round-trip due to a missing eps_decoder method
on the core module, but it's clear it worked at some point.
2012-11-08 23:40:44 -06:00
Brian Crowell
fe14b3e8dd py3k: Get rid of _ParserFile; io.BytesIO does its job 2012-11-08 23:40:43 -06:00
Brian Crowell
cd77e0549a py3k: FIX: TGA missing o8 declaration
Plus, TGA was eligible for a round-trip test in test_imagefile. It has one
now.
2012-11-08 23:40:43 -06:00
Brian Crowell
0dda807da6 py3k: FIX: Bad upside-down check in BmpImagePlugin 2012-11-08 23:40:43 -06:00
Brian Crowell
4a905d91a1 py3k: Remove ancient Python hacks 2012-11-08 23:40:43 -06:00
Christoph Gohlke
69b1b59ea7 py3k: Allow slicing for paths
This is Gohlke's fix for two issues: negative indexes on paths were not
resolved to the correct index, and path slicing didn't work.

His fix for slicing is related to the one found at:

  http://renesd.blogspot.com/2009/07/python3-c-api-simple-slicing-sqslice.html

With this commit, all 79 tests (82 minus the three skipped ones) run
successfully on Python 2.6.8, Python 2.7.3rc2, and Python 3.2.3.
2012-11-08 23:40:43 -06:00
Brian Crowell
00908642a7 py3k: The big push
There are two main issues fixed with this commit:

* bytes vs. str: All file, image, and palette data are now handled as
  bytes. A new _binary module consolidates the hacks needed to do this
  across Python versions. tostring/fromstring methods have been renamed to
  tobytes/frombytes, but the Python 2.6/2.7 versions alias them to the old
  names for compatibility. Users should move to tobytes/frombytes.

  One other potentially-breaking change is that text data in image files
  (such as tags, comments) are now explicitly handled with a specific
  character encoding in mind. This works well with the Unicode str in
  Python 3, but may trip up old code expecting a straight byte-for-byte
  translation to a Python string. This also required a change to Gohlke's
  tags tests (in Tests/test_file_png.py) to expect Unicode strings from
  the code.

* True div vs. floor div: Many division operations used the "/" operator
  to do floor division, which is now the "//" operator in Python 3. These
  were fixed.

As of this commit, on the first pass, I have one failing test (improper
handling of a slice object in a C module, test_imagepath.py) in Python 3,
and three that that I haven't tried running yet (test_imagegl,
test_imagegrab, and test_imageqt). I also haven't tested anything on
Windows. All but the three skipped tests run flawlessly against Pythons
2.6 and 2.7.
2012-11-08 23:40:43 -06:00
Brian Crowell
25676cb6bb py3k: Publish both frombytes and fromstring in C modules for old Python
To ease the transition, frombytes and tobytes need to be declared in both
versions.
2012-11-08 23:40:43 -06:00
Brian Crowell
33dfde7140 py3k: Type coercion is gone
Types aren't automatically converted for operations for you.
2012-11-08 23:40:43 -06:00
Brian Crowell
d2cd57b3cb py3k: Sort by key, not cmp
Py3k only supports key because it's more efficient. Not even sure 2to3
checks for this.
2012-11-08 23:40:43 -06:00
Brian Crowell
db0a68cb0c py3k: Map long type to int
int() is really now long() in py3k, but to avoid breaking 2.6/2.7, we leave
the integer types where they are and just map long to int in py3k.

Also, pretty proud of myself for finding an easy way of detecting py3k.
2012-11-08 23:40:43 -06:00
Brian Crowell
825256c560 py3k: 2to3's "idiom" filter
This is, I guess, a few things the Python devs were just fed up with.

* "while 1" is now "while True"
* Types are compared with isinstance instead of ==
* Sort a list in one go with sorted()

My own twist is to also replace type('') with str, type(()) with tuple,
type([]) with list, type(1) with int, and type(5000.0) with float.
2012-11-08 23:40:43 -06:00
Brian Crowell
836301927e py3k: Change apply() to unpacking syntax
apply() is no longer available in py3k.
2012-11-08 23:40:43 -06:00
Brian Crowell
c8aeba37ba py3k: Integer long literals are no longer valid syntax 2012-11-08 23:40:43 -06:00
Brian Crowell
c10b0a232a py3k: Convert StringIO.StringIO to io.BytesIO
io.BytesIO is already in 2.6. Some of the more obvious bytes literals are
marked in this commit.
2012-11-08 23:40:43 -06:00
Brian Crowell
5363a4a668 py3k: Tkinter module is now tkinter 2012-11-08 23:40:43 -06:00
Brian Crowell
eb1707e090 py3k: __builtin__ module is now builtins 2012-11-08 23:40:43 -06:00
Brian Crowell
83b34d6f7b py3k: Remove Image types import
For awhile now, str == type("") and so on. So we use the appropriate int,
str, basestring, or tuple type where applicable.
2012-11-08 23:40:43 -06:00
Brian Crowell
107c240df1 py3k: Convert backticks to repr()
Backticks are no longer valid syntax for repr().
2012-11-08 23:40:43 -06:00
Brian Crowell
ac897934ee py3k: sys.maxint renamed to sys.maxsize 2012-11-08 23:40:43 -06:00
Brian Crowell
311e7a879f py3k: Use relative imports
In py3k, imports are absolute unless using the "from . import" syntax.

This commit also solves a recursive import between Image, ImageColor, and
ImagePalette by delay-importing ImagePalette in Image.

I'm not too keen on this commit because the syntax is ugly. I might go back
and prefer the prettier "from PIL import".
2012-11-08 23:40:43 -06:00
Brian Crowell
509a585450 py3k: Remove tuples in parameter lists
Py3k no longer supports unpacking tuples in the parameters.
2012-11-08 23:40:43 -06:00
Brian Crowell
cd9fbbfe91 py3k: print is a function
Seriously, if you didn't know that, you've been in a freaking cave, man.
2012-11-08 23:40:43 -06:00
Brian Crowell
07c366e544 py3k: Import reduce function
reduce() is no longer a built-in function in py3k.
2012-11-08 23:40:43 -06:00
Brian Crowell
b3a26550b9 py3k: Use isinstance for numbers and sequences
operator.isNumberType() and .isSequenceType() go away in py3k.
2012-11-08 23:40:42 -06:00
Brian Crowell
8521a38c4a py3k: __nonzero__ is now __bool__ 2012-11-08 23:40:42 -06:00
Brian Crowell
e7c4f69ab6 py3k: Add true Unicode support to OleFileIO
The day has arrived when Python provides an official way to handle Unicode
strings.
2012-11-08 23:40:42 -06:00
Brian Crowell
86b42705a9 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.
2012-11-08 23:40:42 -06:00
Brian Crowell
a900c7940b py3k: Rewrite dictionary support for Tiff ImageFileDictionary
This commit brings in the collections.MutableMapping mixin to provide full
dictionary support for ImageFileDictionary.
2012-11-08 23:40:42 -06:00
Brian Crowell
6c6b7010fa 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.
2012-11-08 23:40:42 -06:00
Brian Crowell
4fa80816fc py3k: Remove callable() function
callable(c) is isinstance(x, collections.Callable) in py3k.
2012-11-08 23:40:42 -06:00
Brian Crowell
cac4ed98ec 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.
2012-11-08 23:40:42 -06:00
Brian Crowell
317fe3be03 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.*.
2012-11-08 23:40:42 -06:00