Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added \x00 symbol to pdf whitespaces. Slightly refactored utils module. #84

Merged
merged 2 commits into from
Mar 27, 2014

Conversation

caxap
Copy link
Contributor

@caxap caxap commented Mar 24, 2014

PyPDF2 unable to parse files with '\x00' character. Actually it is not a whitespace symbol, but I believe that we can just skip it. I've tested this fix for several documents and all looks ok.

Also note as '\x00' is not a whitespace, so '\x00'.isspace() will be False.

@mstamy2
Copy link
Collaborator

mstamy2 commented Mar 24, 2014

Looks like a good fix for this issue - utils.py should define a list of whitespace characters anyway.

The only problem I am having is with map(). With the line
WHITESPACES = map(b_, [' ', '\n', '\r', '\t', '\x00'])
I am getting various read errors, which mean that for some reason the whitespace methods aren't working properly. (In Python 3)

If I instead write
WHITESPACES = [b_(' '), b_('\n'), b_('\r'), b_('\t'), b_('\x00')]
then everything works as intended.

I believe this is caused by differences between map() in Python 2 and Python 3.

@caxap
Copy link
Contributor Author

caxap commented Mar 24, 2014

Oh, yes. Sorry for that, I'm "Python 2" guy :). So I can update fix.

@mstamy2
Copy link
Collaborator

mstamy2 commented Mar 24, 2014

Thanks!
Sorry, it can be a hassle to maintain compatibility with Python 2 and 3 simultaneously.

@caxap
Copy link
Contributor Author

caxap commented Mar 27, 2014

Updated!

mstamy2 added a commit that referenced this pull request Mar 27, 2014
Added \x00 symbol to pdf whitespaces. Slightly refactored utils module.
@mstamy2 mstamy2 merged commit 1b839a5 into py-pdf:master Mar 27, 2014
@mstamy2
Copy link
Collaborator

mstamy2 commented Mar 27, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants