diff --git a/NEWS b/NEWS index bc4ef54..ffbf8e5 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/feedparser/feedparser.py b/feedparser/feedparser.py index 5c039a4..8ca8067 100644 --- a/feedparser/feedparser.py +++ b/feedparser/feedparser.py @@ -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