Revision: 4113
Author: pekka.klarck
Date: Thu Sep 23 10:35:57 2010
Log: Global workaround for os.listdir bug on Jython < 2.5.2. This fixes
issue 643 and possible other problems caused by the same underlying bug.
The global workaround also made the parsing specific fix unnecessary.
http://code.google.com/p/robotframework/source/detail?r=4113
Modified:
/trunk/src/robot/__init__.py
/trunk/src/robot/parsing/populators.py
=======================================
--- /trunk/src/robot/__init__.py Mon Sep 6 04:15:52 2010
+++ /trunk/src/robot/__init__.py Thu Sep 23 10:35:57 2010
@@ -13,11 +13,25 @@
# 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
+
+if sys.platform.startswith('java') and sys.version_info[:3] < (2,5,2):
+ # Global workaround for http://bugs.jython.org/issue1593
+ 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
+
+
if 'pythonpathsetter' not in sys.modules:
import pythonpathsetter
from output import Output, CommandLineMonitor, LOGGER
=======================================
--- /trunk/src/robot/parsing/populators.py Fri Jul 2 03:19:20 2010
+++ /trunk/src/robot/parsing/populators.py Thu Sep 23 10:35:57 2010
@@ -147,10 +147,6 @@
def _list_dir(self, path):
# os.listdir returns Unicode entries when path is Unicode
names = os.listdir(utils.unic(path))
- # http://bugs.jython.org/issue1593
- if utils.is_jython:
- from java.lang import String
- names = [utils.unic(String(n)) for n in names]
for name in sorted(names, key=unicode.lower):
yield name, os.path.join(path, name)