[pypy-svn] r55924 - in pypy/branch/2.5-features/pypy: lib objspace/std
bgola at codespeak.net
bgola at codespeak.net
Tue Jun 17 15:45:26 CEST 2008
Author: bgola
Date: Tue Jun 17 15:45:23 2008
New Revision: 55924
Modified:
pypy/branch/2.5-features/pypy/lib/_exceptions.py
pypy/branch/2.5-features/pypy/objspace/std/unicodeobject.py
Log:
UnicodeWarning class...
Modified: pypy/branch/2.5-features/pypy/lib/_exceptions.py
==============================================================================
--- pypy/branch/2.5-features/pypy/lib/_exceptions.py (original)
+++ pypy/branch/2.5-features/pypy/lib/_exceptions.py Tue Jun 17 15:45:23 2008
@@ -84,7 +84,8 @@
+-- SyntaxWarning
+-- OverflowWarning
+-- RuntimeWarning
- +-- FutureWarning"""
+ +-- FutureWarning
+ +-- UnicodeWarning"""
class Exception:
"""Common base class for all exceptions."""
@@ -383,6 +384,10 @@
class SyntaxWarning(Warning):
"""Base class for warnings about dubious syntax."""
+class UnicodeWarning(Warning):
+ """Base class for warnings about Unicode related problems, mostly
+ related to conversion problems."""
+
class MemoryError(StandardError):
"""Out of memory."""
Modified: pypy/branch/2.5-features/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/branch/2.5-features/pypy/objspace/std/unicodeobject.py (original)
+++ pypy/branch/2.5-features/pypy/objspace/std/unicodeobject.py Tue Jun 17 15:45:23 2008
@@ -76,15 +76,19 @@
w_uni2 = uni_from_str(space, w_str)
except OperationError, e:
if e.match(space, space.w_UnicodeDecodeError):
- word = "unequal" if inverse else "equal"
+ if inverse:
+ word = "unequal"
+ else :
+ word = "equal"
msg = "Unicode %s comparison failed to convert both arguments\
to Unicode - interpreting them as being unequal" % word
space.warn(msg, space.w_UnicodeWarning)
return space.newbool(inverse)
raise
- if inverse:
- return space.not_(space.eq(w_uni, w_uni2))
- return space.eq(w_uni, w_uni2)
+ result = space.eq(w_uni, w_uni2)
+ if inverse:
+ return space.not_(result)
+ return result
def str_w__Unicode(space, w_uni):
return space.str_w(str__Unicode(space, w_uni))
More information about the Pypy-commit
mailing list