[pypy-svn] r14819 - pypy/dist/pypy/objspace/std

ac at codespeak.net ac at codespeak.net
Wed Jul 20 16:57:14 CEST 2005


Author: ac
Date: Wed Jul 20 16:57:13 2005
New Revision: 14819

Modified:
   pypy/dist/pypy/objspace/std/intobject.py
Log:
Fix oct/hex.

Modified: pypy/dist/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/intobject.py	(original)
+++ pypy/dist/pypy/objspace/std/intobject.py	Wed Jul 20 16:57:13 2005
@@ -404,31 +404,10 @@
     return space.newfloat(x)
 
 def oct__Int(space, w_int1):
-    x = w_int1.intval
-    if x < 0:
-        ## XXX what about this warning?
-        #if (PyErr_Warn(PyExc_FutureWarning,
-        #           "hex()/oct() of negative int will return "
-        #           "a signed string in Python 2.4 and up") < 0)
-        #    return NULL;
-        pass
-    if x == 0:
-        ret = "0"
-    else:
-        ret = "0%lo" % x
-    return space.wrap(ret)
+    return space.wrap(oct(w_int1.intval))
 
 def hex__Int(space, w_int1):
-    x = w_int1.intval
-    if x < 0:
-        ## XXX what about this warning?
-        #if (PyErr_Warn(PyExc_FutureWarning,
-        #           "hex()/oct() of negative int will return "
-        #           "a signed string in Python 2.4 and up") < 0)
-        #    return NULL;
-        pass
-    ret = "0x%lx" % x
-    return space.wrap(ret)
+    return space.wrap(hex(w_int1.intval))
 
 def getnewargs__Int(space, w_int1):
     return space.newtuple([W_IntObject(space, w_int1.intval)])



More information about the Pypy-commit mailing list