Frank Wierzbicki avatar Frank Wierzbicki committed 005b971

Move java imports out of functions for pep8 and perf.

Comments (0)

Files changed (4)

     del sys, MockThreading
+    from java.lang import Object
+    from java.math import BigDecimal
+    from org.python.core import Py
+except ImportError:
+    #Not Jython, ignore.
+    pass
 except AttributeError:
 import dbexts, cmd, sys, os
+if sys.platform.startswith("java"):
+    import java.lang.String
 Isql works in conjunction with dbexts to provide an interactive environment
 for database work.
         if len(self.isql.sqlbuffer) > 0:
             prompt = "... "
         return prompt
-    if == 'java':
+    if sys.platform.startswith("java"):
         def __tojava__(self, cls):
-            import java.lang.String
             if cls == java.lang.String:
                 return self.__str__()
             return False
 import sys,string,os,re
+if sys.platform.startswith("java"):
+    from java.lang import System
+    from org.python.core.Py import newString
 ### Platform specific APIs
 _libc_search = re.compile(r'(__libc_init)'
 def _java_getprop(name,default):
-    from java.lang import System
-    from org.python.core.Py import newString
         return newString(System.getProperty(name))


+import unittest
+from test import test_support
+from decimal import Decimal
+from java.math import BigDecimal
+class TestJavaDecimal(unittest.TestCase):
+    def test_decimal(self):
+        self.assertTrue(hasattr(Decimal, "__tojava__"))
+        x = Decimal("1.1")
+        y = x.__tojava__(BigDecimal)
+        self.assertTrue(isinstance(y, BigDecimal))
+if __name__ == '__main__':
+    unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.