Revision: 6e01ce5282cf
Author:   Pekka Klärck
Date:     Tue Feb 21 04:48:15 2012
Log: Fixed importing Java libraries in packages with robotframework.jar and stand-alone Jython in general.

Update issue 1062
Status: Done
Labels: Type-Task Priority-High
I was able to reproduce the problem and also to fix it. My earlier importing
related fixes and clean-ups had broken the workaround we have for importing
Java classes in packages with stand-alone Jython. For more information
see issue 515 and http://bugs.jython.org/issue1778514.

The reason this bug had slipped through is that we don't have CI environment
for running tests with stand-alone Jython (or robotframework.jar that uses it
internally). Although we ought to have executed these tests at some point
before the final release, it was great that you spotted the bug already at this point. The fix will be included in the next RF 2.7 preview release (b2 or rc1).
http://code.google.com/p/robotframework/source/detail?r=6e01ce5282cf

Modified:
 /src/robot/utils/importer.py

=======================================
--- /src/robot/utils/importer.py        Wed Jan  4 11:40:02 2012
+++ /src/robot/utils/importer.py        Tue Feb 21 04:48:15 2012
@@ -120,10 +120,11 @@
             try:
                 return __import__(name, fromlist=fromlist)
             except ImportError:
-                # Hack to support standalone Jython:
+ # Hack to support standalone Jython. For more information, see: # http://code.google.com/p/robotframework/issues/detail?id=515
+                # http://bugs.jython.org/issue1778514
                 if fromlist and retry and sys.platform.startswith('java'):
-                    __import__(name)
+                    __import__('%s.%s' % (name, fromlist[0]))
                     return self._import(name, fromlist, retry=False)
                 raise
         except:
@@ -224,7 +225,7 @@

     def import_(self, name):
         parent_name, lib_name = name.rsplit('.', 1)
-        parent = self._import(parent_name, [str(lib_name)])
+        parent = self._import(parent_name, fromlist=[str(lib_name)])
         try:
             imported = getattr(parent, lib_name)
         except AttributeError:

Reply via email to