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

Error when in addFromFile using file-like object #245

Closed
ajoaoff opened this issue Sep 4, 2015 · 0 comments
Closed

Error when in addFromFile using file-like object #245

ajoaoff opened this issue Sep 4, 2015 · 0 comments

Comments

@ajoaoff
Copy link

ajoaoff commented Sep 4, 2015

When I try to add a pdf from a file using
pdf.addFromFile(open(f, "rb"))

I get this error 'file' object has no attribute 'encode'.
Taking a look at the code, I saw that self.addFromURI(f) is always called, even when f is a file-like obj. Shouldn't the code

def addFromFile(self, f):
    if hasattr(f, "read"):
        self.files.append(f)
    self.addFromURI(f)

be changed to

def addFromFile(self, f):
    if hasattr(f, "read"):
        self.files.append(f)
    else:
        self.addFromURI(f)
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

No branches or pull requests

2 participants