[issue8754] ImportError: quote bad module name in message
Éric Araujo
report at bugs.python.org
Sun Nov 21 04:28:17 CET 2010
Éric Araujo <merwok at netwok.org> added the comment:
Just for fun, I tried using my tiny understanding of C to write a patch. I am attaching my current result, which passes the test suite except for test_unittest:
FAIL: test_loadTestsFromName__unknown_module_name (unittest.test.test_loader.Test_TestLoader)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/wok/code/hg/cpython/3.2/fix-import-repr/Lib/unittest/test/test_loader.py", line 240, in test_loadTestsFromName__unknown_module_name
loader.loadTestsFromName('sdasfasfasdf')
ImportError: No module named 0I�
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wok/code/hg/cpython/3.2/fix-import-repr/Lib/unittest/test/test_loader.py", line 242, in test_loadTestsFromName__unknown_module_name
self.assertEqual(str(e), "No module named 'sdasfasfasdf'")
AssertionError: 'No module named 0I�\x01' != "No module named 'sdasfasfasdf'"
- No module named 0I�
+ No module named 'sdasfasfasdf'
======================================================================
FAIL: test_loadTestsFromNames__unknown_module_name (unittest.test.test_loader.Test_TestLoader)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib/unittest/test/test_loader.py", line 620, in test_loadTestsFromNames__unknown_module_name
loader.loadTestsFromNames(['sdasfasfasdf'])
ImportError: No module named HB�
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Lib/unittest/test/test_loader.py", line 622, in test_loadTestsFromNames__unknown_module_name
self.assertEqual(str(e), "No module named 'sdasfasfasdf'")
AssertionError: 'No module named HB�\x01' != "No module named 'sdasfasfasdf'"
- No module named HB�
+ No module named 'sdasfasfasdf'
test_imp{,ort,ortlib} pass, though. Maybe someone will take my patch and fix the PyObject_Repr call and error checking. It was a fun bit of experimenting with help from kind people on IRC :)
----------
keywords: +patch
Added file: http://bugs.python.org/file19726/import-repr.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8754>
_______________________________________
More information about the Python-bugs-list
mailing list