Repository navigation
fix for #272 on SmartOS. Stripping whitespace from string.whitespace. - #2820
markmiscavage wants to merge 1 commit into
Conversation
|
At least this breaks all the existing CI builds. Examples on Mac: Python 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> string.whitespace
'\t\n\x0b\x0c\r '
>>> string.whitespace.strip()
''
>>>Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> string.whitespace
' \t\n\r\x0b\x0c'
>>> string.whitespace.strip()
''
>>>What do you get for
try:
import locale
locale_lang, locale_enc = locale.getlocale()
if locale_enc is None:
locale_lang, locale_enc = locale.getdefaultlocale()
b_whitespace = b_whitespace.decode(locale_enc) # Line 33
except:
passThat bare |
|
The spec (http://netpbm.sourceforge.net/doc/ppm.html) defines whitespace as: Which are essentially the old pre-locale default whitespace characters. So, we should probably just assign a fixed list, rather than pulling the locale dependent whitespace characters from the string module. e.g.: |
Python 2.7.14 (default, Oct 3 2017, 16:34:09)
[GCC 4.9.4] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import string
>>> string.whitespace
'\t\n\x0b\x0c\r \xa0'
>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'UTF-8')`Notice the space after the \r in string.whitespace, thats what was causing the problem for me. Switching it to a fixed list sounds sane to me. |
|
I had a quick test with hugovk@5867ce0 but it's failing selftest.py on Python 3: https://travis-ci.org/hugovk/Pillow/builds/295933112 selftest and the full tests pass for me locally. |
|
Looks like it needs to be done as a bytes object: https://github.com/wiredfool/Pillow/blob/pr_2820/PIL/PpmImagePlugin.py#L27 |
Fixes #272
Strips the whitespace that comes through on the
string.whitespacecall on SmartOS systems.Changes proposed in this pull request: