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

get_coauthors() throwing UnicodeEncodeError #33

Closed
echelon-debug opened this issue Jun 21, 2017 · 6 comments
Closed

get_coauthors() throwing UnicodeEncodeError #33

echelon-debug opened this issue Jun 21, 2017 · 6 comments
Assignees
Labels

Comments

@echelon-debug
Copy link

echelon-debug commented Jun 21, 2017

When trying to get coauthors from an author, I receive the following exception:

line 232, in get_coauthors
    coauthor_name = '{0} {1}'.format(given_name, surname)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 2: ordinal not in range(128)

(I couldn't wait so I fixed this locally on my machine by simply encoding the given name and surname as UTF-8 at line 232)

@jkitchin
Copy link
Collaborator

Can you provide a short script that causes this error?

@echelon-debug
Copy link
Author

Yes - though I've just left town for the weekend. Will get to this Monday.

@echelon-debug
Copy link
Author

echelon-debug commented Jun 27, 2017

I'm currently being throttled for too many requests so I can't test this unfortunately, though something like this was causing the exception for me before:

from scopus.scopus_author import ScopusAuthor
author = ScopusAuthor(25935090600)
print [a.name for a in author.get_coauthors()]

@jkitchin
Copy link
Collaborator

I wonder it that is a python 2 issue. This worked fine for me with python3.

@echelon-debug
Copy link
Author

This is quite likely, as I'm using Python 2, and I believe there are some differences in how strings are handled between the two.

@Michael-E-Rose Michael-E-Rose self-assigned this Jul 20, 2017
@Michael-E-Rose Michael-E-Rose changed the title get_coauthors() throwing exception get_coauthors() throwing UnicodeEncodeError Jul 26, 2017
@Michael-E-Rose
Copy link
Contributor

Indeed there are differences. But the fix is simple (though hard to find): Simply make the concatenated name of the coauthors a unicode object.

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

No branches or pull requests

3 participants