1. jython
  2. jython

Commits

Jeff Allen  committed f731a59 Merge

Merge buffer development

  • Participants
  • Parent commits 2751805, 7dac332
  • Branches default

Comments (0)

Files changed (3)

File Lib/test/bark.py

View file
  • Ignore whitespace
 from __future__ import print_function
 
+import sys
 from java.io import Serializable
 from java.util.concurrent import Callable
 
     def call(self):
         # Using print forces use of PySystemState and shows it's initialized
         print("%s barks %s times" % (self.name, self.number))
+        # Verify that site has been imported and therefore
+        # site-packages and distutils/setuptools goodness is available
+        return "site" in sys.modules
 
     def __eq__(self, other):
         return self.name == other.name and self.number == other.number

File Lib/test/test_java_integration.py

View file
  • Ignore whitespace
         tempdir = tempfile.mkdtemp()
         try:
             SerializableProxies.serialized_path = tempdir
-            import bark #importlib.import_module("bark")
+            import bark
             dog = bark.Dog()
             self.assertEqual(dog.whoami(), "Rover")
             self.assertEqual(dog.serialVersionUID, 1)
     public static void main(String[] args) {
         Dog dog = new Dog();
         try {
-            dog.call();
+            Boolean b = (Boolean)(dog.call());
+            if (!b) {
+                throw new RuntimeException("Expected site module to be imported");
+            }
         }
         catch(Exception e) {
             System.err.println(e);
                    "-classpath", classpath, "BarkTheDog"]
             env = dict(os.environ)
             env.update(JYTHONPATH=os.path.normpath(os.path.join(__file__, "..")))
-            self.assertEqual(
-                subprocess.check_output(cmd, env=env, universal_newlines=True),
-                    "Class defined on CLASSPATH <type 'org.python.test.bark.Dog'>\n"
-                    "Rover barks 42 times\n")
+            self.assertRegexpMatches(
+                subprocess.check_output(cmd, env=env, universal_newlines=True,
+                                        stderr=subprocess.STDOUT),
+                r"^\*sys-package-mgr\*: processing new jar, '.+?/proxies.jar'\n"
+                 "Class defined on CLASSPATH <type 'org.python.test.bark.Dog'>\n"
+                 "Rover barks 42 times\n$".format(tempdir))
         finally:
             pass
             # print "Will not remove", tempdir

File src/org/python/core/Py.java

View file
  • Ignore whitespace
             return;
         }
 
+        if (Options.importSite) {
+            // Ensure site-packages are available before attempting to import module.
+            // This step enables supporting modern Python apps when using proxies
+            // directly from Java (eg through clamp).
+            imp.load("site");
+        }
         PyObject mod = imp.importName(module.intern(), false);
         PyType pyc = (PyType)mod.__getattr__(pyclass.intern());