This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author naufraghi
Recipients naufraghi
Date 2008-07-31.07:13:08
SpamBayes Score 0.0025910106
Marked as misclassified No
Message-id <1217488390.82.0.966024621847.issue3475@psf.upfronthosting.co.za>
In-reply-to
Content
Playing with PyInstaller I have found that the final part of 
_elementtree.c:

Index: Modules/_elementtree.c
===================================================================
--- Modules/_elementtree.c      (revisione 59540)
+++ Modules/_elementtree.c      (copia locale)
@@ -2780,7 +2780,10 @@

       );

-    PyRun_String(bootstrap, Py_file_input, g, NULL);
+    if (PyRun_String(bootstrap, Py_file_input, g, NULL) == NULL)
+        return;

    elementpath_obj = PyDict_GetItemString(g, "ElementPath");

execute a bit of python code without checking the return value.
That can lead to weird things playing with import hooks,
for example an assert like this can fail:

Index: Lib/test/test_elemettree.py
===================================================================
--- Lib/test/test_elemettree.py (revisione 0)
+++ Lib/test/test_elemettree.py (revisione 0)
@@ -0,0 +1,21 @@
+#! /usr/bin/env python
+
+def importHook(*args, **kwargs):
+    if 'xml.etree' in args:
+        raise ImportError
+    else:
+        return __real__import__(*args, **kwargs)
+
+import os
+import __builtin__
+__real__import__ = __builtin__.__import__
+__builtin__.__import__ = importHook
+
+try:
+    import xml.etree.cElementTree as cET
+except ImportError:
+    pass
+else:
+    out = os.popen("python -c 'import xml.etree.cElementTree as cET; 
print dir(cET)'").read().strip()
+    assert str(dir(cET)) == out, (str(dir(cET)), out)
+
History
Date User Action Args
2008-07-31 07:13:10naufraghisetrecipients: + naufraghi
2008-07-31 07:13:10naufraghisetmessageid: <1217488390.82.0.966024621847.issue3475@psf.upfronthosting.co.za>
2008-07-31 07:13:10naufraghilinkissue3475 messages
2008-07-31 07:13:08naufraghicreate