Skip to content

Prevent http.client.InvalidURL exception on set_article_url() - #6

Open
gbnegrini wants to merge 1 commit into
mfcovington:developfrom
gbnegrini:develop
Open

Prevent http.client.InvalidURL exception on set_article_url()#6
gbnegrini wants to merge 1 commit into
mfcovington:developfrom
gbnegrini:develop

Conversation

@gbnegrini

Copy link
Copy Markdown

Hi @mfcovington!
I came across an uncaught "http.client.InvalidURL: URL can't contain control characters" exception while running pubmed-lookup on a project.
The issue was caused by a weird record['DOI'] string containing a whitespace (PMID: 31207675). The error can be reproduced running the code below:

from pubmed_lookup import PubMedLookup, Publication
email = ''
pmid = '31207675'
lookup = PubMedLookup(pmid, email)
publication = Publication(lookup, resolve_doi=True)

I've added some split() and join() to set_article_url() method to remove whitespace characters from URLs. I don't think this is such a common issue, but I hope this change can help.

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.

1 participant