Revision: 009ab4097efb
Author: Pekka Klärck
Date: Fri Jan 13 02:57:20 2012
Log: moved jython workarounds for separate module
http://code.google.com/p/robotframework/source/detail?r=009ab4097efb
Added:
/src/robot/jythonworkarounds.py
Modified:
/src/robot/__init__.py
=======================================
--- /dev/null
+++ /src/robot/jythonworkarounds.py Fri Jan 13 02:57:20 2012
@@ -0,0 +1,37 @@
+# Copyright 2008-2011 Nokia Siemens Networks Oyj
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import sys
+from java.lang import String
+
+
+# Global workaround for os.listdir bug http://bugs.jython.org/issue1593
+# This bug has been fixed in Jython 2.5.2.
+if sys.version_info[:3] < (2, 5, 2):
+ os._orig_listdir = os.listdir
+ def listdir(path):
+ items = os._orig_listdir(path)
+ if isinstance(path, unicode):
+ items = [unicode(String(i).toString()) for i in items]
+ return items
+ os.listdir = listdir
+
+
+# Global workaround for os.stat bug on Windows
http://bugs.jython.org/issue1658
+# The bug still exists in Jython 2.5.2 but the workaround doesn't work
anymore.
+if os.sep == '\\' and sys.version_info[:3] < (2, 5, 2):
+ os._posix = os.JavaPOSIX(os.PythonPOSIXHandler())
+ os._native_posix = False
+
=======================================
--- /src/robot/__init__.py Mon Dec 19 04:55:53 2011
+++ /src/robot/__init__.py Fri Jan 13 02:57:20 2012
@@ -13,35 +13,15 @@
# limitations under the License.
import sys
-import os
-
if __name__ == '__main__':
sys.stderr.write("Use 'runner' or 'rebot' for executing.\n")
sys.exit(252) # 252 == DATA_ERROR
-
-# Global workaround for os.listdir bug http://bugs.jython.org/issue1593
-# This bug has been fixed in Jython 2.5.2 RC 2
-if sys.platform.startswith('java') and sys.version_info[:3] < (2,5,2):
- from java.lang import String
- def listdir(path):
- items = os._listdir(path)
- if isinstance(path, unicode):
- items = [unicode(String(i).toString()) for i in items]
- return items
- os._listdir = os.listdir
- os.listdir = listdir
-
-# Global workaround for os.stat bug http://bugs.jython.org/issue1658
-# Jython 2.5.2 RC 2 still contains this bug, but additionally the
workaround used
-# here does not work on that version either.
-if sys.platform.startswith('java') and os.sep == '\\' and sys.version_info
< (2,5,2):
- os._posix = os.JavaPOSIX(os.PythonPOSIXHandler())
- os._native_posix = False
-
if 'pythonpathsetter' not in sys.modules:
import pythonpathsetter
+if sys.platform.startswith('java'):
+ from robot import jythonworkarounds
from robot.conf import RobotSettings, RebotSettings
from robot.errors import (DataError, Information, INFO_PRINTED, DATA_ERROR,
STOPPED_BY_USER, FRAMEWORK_ERROR)