Skip to content

Instantly share code, notes, and snippets.

@eliben
Last active December 20, 2015 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliben/6202493 to your computer and use it in GitHub Desktop.
Save eliben/6202493 to your computer and use it in GitHub Desktop.
import io
from test.support import import_fresh_module
import csv
csv_other = import_fresh_module('csv', fresh=['_csv', 'csv'])
f = io.StringIO('foo\x00,bar\nbaz,42')
reader = csv.reader(f)
try:
for row in reader:
print(row)
except csv.Error as e:
print('Caught csv.error', e)
except Exception as e:
print('Caught Exception', e)
@eliben
Copy link
Author

eliben commented Aug 10, 2013

This line:

csv_other = import_fresh_module('csv', fresh=['_csv', 'csv'])

Causes the first except clause to fail, because the thrown exception is a "different" csv.Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment