Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Commit

Permalink
Catch UnicodeEncodeError when opening a Unicode filename
Browse files Browse the repository at this point in the history
Fixes issue 326. Thanks to Barry Warsaw for reporting this!

git-svn-id: http://feedparser.googlecode.com/svn/trunk@681 73d2b349-402e-0410-baf4-070fd12ab5b7
  • Loading branch information
kurtmckee committed Feb 9, 2012
1 parent 6e2a1f9 commit a1f8f05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -8,6 +8,7 @@ Changes coming in the next release:
* Issue 321 (malformed URIs can cause ValueError to be thrown)
* Issue 323 (installing chardet causes 11 unit test failures)
* Issue 325 (map `description_detail` to `summary_detail`)
* Issue 326 (Unicode filename causes UnicodeEncodeError if locale is ASCII)

5.1 - December 2, 2011
* Extensive, extensive unit test refactoring
Expand Down
6 changes: 5 additions & 1 deletion feedparser/feedparser.py
Expand Up @@ -2979,7 +2979,11 @@ def _open_resource(url_file_stream_or_string, etag, modified, agent, referrer, h
# try to open with native open function (if url_file_stream_or_string is a filename)
try:
return open(url_file_stream_or_string, 'rb')
except IOError:
except (IOError, UnicodeEncodeError):
# if url_file_stream_or_string is a unicode object that
# cannot be converted to the encoding returned by
# sys.getfilesystemencoding(), a UnicodeEncodeError
# will be thrown
pass

# treat url_file_stream_or_string as string
Expand Down

0 comments on commit a1f8f05

Please sign in to comment.