Revision: 4281
Author: pekka.klarck
Date: Thu Nov 11 08:48:32 2010
Log: Some IronPython 2.6 compatibility (issue 154)
http://code.google.com/p/robotframework/source/detail?r=4281
Modified:
/trunk/src/robot/running/signalhandler.py
/trunk/src/robot/utils/abstractxmlwriter.py
/trunk/src/robot/utils/domwrapper.py
/trunk/src/robot/utils/unic.py
=======================================
--- /trunk/src/robot/running/signalhandler.py Thu Sep 16 00:17:34 2010
+++ /trunk/src/robot/running/signalhandler.py Thu Nov 11 08:48:32 2010
@@ -12,8 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import signal
import sys
+try:
+ import signal
+except ImportError:
+ signal = None # IronPython 2.6 doesn't have signal module by default
from robot.errors import ExecutionFailed
from robot.output import LOGGER
@@ -39,8 +42,9 @@
raise ExecutionFailed('Execution terminated by signal', exit=True)
def start(self):
- signal.signal(signal.SIGINT, self)
- signal.signal(signal.SIGTERM, self)
+ if signal:
+ signal.signal(signal.SIGINT, self)
+ signal.signal(signal.SIGTERM, self)
def start_running_keyword(self, in_teardown):
self._running_keyword = True
=======================================
--- /trunk/src/robot/utils/abstractxmlwriter.py Mon May 31 05:21:54 2010
+++ /trunk/src/robot/utils/abstractxmlwriter.py Thu Nov 11 08:48:32 2010
@@ -12,11 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
from unic import unic
-# See http://www.spamagogo.com/wiki/index.php/Illegal_XML_characters
_ILLEGAL_CHARS_IN_XML =
u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e' \
+
u'\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\ufffe'
@@ -43,5 +41,7 @@
def _encode(self, message):
message = unic(message)
for char in _ILLEGAL_CHARS_IN_XML:
- message = message.replace(char, '')
+ # Avoid bug http://ironpython.codeplex.com/workitem/29402
+ if char in message:
+ message = message.replace(char, '')
return message
=======================================
--- /trunk/src/robot/utils/domwrapper.py Thu Nov 11 08:25:29 2010
+++ /trunk/src/robot/utils/domwrapper.py Thu Nov 11 08:48:32 2010
@@ -21,8 +21,13 @@
except ImportError:
try:
import xml.etree.ElementTree as ET
+ # Raises ImportError due to missing expact on IronPython by
default
+ ET.parse(StringIO('<test/>'))
except ImportError:
- import elementtree.ElementTree as ET
+ try:
+ import elementtree.ElementTree as ET
+ except ImportError:
+ raise ImportError('No valid ElementTree XML parser module
found')
class DomWrapper(object):
=======================================
--- /trunk/src/robot/utils/unic.py Mon May 31 05:21:54 2010
+++ /trunk/src/robot/utils/unic.py Thu Nov 11 08:48:32 2010
@@ -15,21 +15,27 @@
import sys
+# Need different unic implementations for different Pythons because:
+# 1) Importing unicodedata module on Jython takes a very long time, and
doesn't
+# seem to be necessary as Java probably already handles normalization.
+# Furthermore, Jython on Java 1.5 doesn't even have unicodedata.normalize.
+# 2) IronPython 2.6 doesn't have unicodedata and probably doesn't need it.
+# 3) CPython doesn't automatically normalize Unicode strings.
+
if sys.platform.startswith('java'):
from java.lang import Object, Class
-
def unic(item, *args):
# http://bugs.jython.org/issue1564
if isinstance(item, Object) and not isinstance(item, Class):
item = item.toString() # http://bugs.jython.org/issue1563
return _unic(item, *args)
+elif sys.platform == 'cli':
+ def unic(item, *args):
+ return _unic(item, *args)
+
else:
- # importing unicodedata on jython takes a very long time, and does not
seem
- # necessary as java probably already handles normalization. Furthermore
- # java 1.5 does not even have unicodedata.normalize
from unicodedata import normalize
-
def unic(item, *args):
return normalize('NFC', _unic(item, *args))