Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r48004:30686d08358a
Date: 2011-10-13 00:20 +0200
http://bitbucket.org/pypy/pypy/changeset/30686d08358a/
Log: Fix str.__name__ and remove basestring
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -228,7 +228,7 @@
def getdocstring(self, space):
if self.co_consts_w: # it is probably never empty
w_first = self.co_consts_w[0]
- if space.is_true(space.isinstance(w_first, space.w_basestring)):
+ if space.is_true(space.isinstance(w_first, space.w_unicode)):
return w_first
return space.w_None
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1457,7 +1457,7 @@
if not isinstance(prog, codetype):
filename = '<string>'
- if not isinstance(prog, basestring):
+ if not isinstance(prog, str):
if isinstance(prog, file):
filename = prog.name
prog = prog.read()
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -39,9 +39,10 @@
from pypy.module._io.interp_bufferedio import (W_BufferedRandom,
W_BufferedWriter, W_BufferedReader)
- if not (space.isinstance_w(w_file, space.w_basestring) or
- space.isinstance_w(w_file, space.w_int) or
- space.isinstance_w(w_file, space.w_long)):
+ if not (space.isinstance_w(w_file, space.w_unicode) or
+ space.isinstance_w(w_file, space.w_str) or
+ space.isinstance_w(w_file, space.w_int) or
+ space.isinstance_w(w_file, space.w_long)):
raise operationerrfmt(space.w_TypeError,
"invalid file: %s", space.str_w(space.repr(w_file))
)
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -374,7 +374,6 @@
"Type": "space.w_type",
"String": "space.w_str",
"Unicode": "space.w_unicode",
- "BaseString": "space.w_basestring",
"Dict": "space.w_dict",
"Tuple": "space.w_tuple",
"List": "space.w_list",
diff --git a/pypy/module/posix/interp_posix.py
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1067,7 +1067,7 @@
def confname_w(space, w_name, namespace):
# XXX slightly non-nice, reuses the sysconf of the underlying os module
- if space.is_true(space.isinstance(w_name, space.w_basestring)):
+ if space.is_true(space.isinstance(w_name, space.w_unicode)):
try:
num = namespace[space.str_w(w_name)]
except KeyError:
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -341,11 +341,11 @@
"'%s' object does not define __format__",
typename)
w_res = space.get_and_call_function(w_descr, w_obj, w_format_spec)
- if not space.is_true(space.isinstance(w_res, space.w_basestring)):
+ if not space.is_true(space.isinstance(w_res, space.w_unicode)):
typename = space.type(w_obj).getname(space)
restypename = space.type(w_res).getname(space)
raise operationerrfmt(space.w_TypeError,
- "%s.__format__ must return string or unicode, not %s",
+ "%s.__format__ must return a string, not %s",
typename, restypename)
return w_res
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -39,7 +39,6 @@
w_long = W_Object()
w_tuple = W_Object()
w_str = W_Object()
- w_basestring = W_Object()
w_unicode = W_Object()
w_type = W_Object()
w_instance = W_Object()
diff --git a/pypy/objspace/std/basestringtype.py
b/pypy/objspace/std/basestringtype.py
deleted file mode 100644
--- a/pypy/objspace/std/basestringtype.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from pypy.objspace.std.stdtypedef import StdTypeDef
-
-
-basestring_typedef = StdTypeDef("basestring",
- __doc__ = ("basestring cannot be instantiated; "
- "it is the base for str and unicode.")
- )
diff --git a/pypy/objspace/std/fake.py b/pypy/objspace/std/fake.py
--- a/pypy/objspace/std/fake.py
+++ b/pypy/objspace/std/fake.py
@@ -100,15 +100,9 @@
fake__new__.func_name = "fake__new__" + cpy_type.__name__
kw['__new__'] = gateway.interp2app(fake__new__)
- if cpy_type.__base__ is not object and not issubclass(cpy_type, Exception):
- assert cpy_type.__base__ is basestring, cpy_type
- from pypy.objspace.std.basestringtype import basestring_typedef
- base = basestring_typedef
- else:
- base = None
class W_Fake(W_Object):
typedef = StdTypeDef(
- cpy_type.__name__, base, **kw)
+ cpy_type.__name__, **kw)
def __init__(w_self, space, val):
w_self.val = val
w_self.space = space
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -528,7 +528,7 @@
# in simplest case
if space.isinstance_w(w_values, space.w_dict) or \
(space.lookup(w_values, '__getitem__') and
- not space.isinstance_w(w_values, space.w_basestring)):
+ not space.isinstance_w(w_values, space.w_unicode)):
return format(space, w_format, [w_values], w_values, do_unicode)
else:
return format(space, w_format, [w_values], None, do_unicode)
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -46,7 +46,6 @@
from pypy.objspace.std.tupletype import tuple_typedef
from pypy.objspace.std.listtype import list_typedef
from pypy.objspace.std.dicttype import dict_typedef
- from pypy.objspace.std.basestringtype import basestring_typedef
from pypy.objspace.std.stringtype import str_typedef
from pypy.objspace.std.bytearraytype import bytearray_typedef
from pypy.objspace.std.typetype import type_typedef
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -68,10 +68,11 @@
w_type = self.gettypeobject(typedef)
self.builtin_types[typedef.name] = w_type
setattr(self, 'w_' + typedef.name, w_type)
- del self.builtin_types['unicode']
+ self.w_unicode = self.w_str
+ self.w_text = self.w_str
+ self.w_str = self.w_bytes
self.builtin_types['str'] = self.w_unicode
self.builtin_types['bytes'] = self.w_str
- self.w_text = self.w_unicode
self.builtin_types["NotImplemented"] = self.w_NotImplemented
self.builtin_types["Ellipsis"] = self.w_Ellipsis
diff --git a/pypy/objspace/std/stringtype.py b/pypy/objspace/std/stringtype.py
--- a/pypy/objspace/std/stringtype.py
+++ b/pypy/objspace/std/stringtype.py
@@ -1,6 +1,5 @@
from pypy.interpreter import gateway
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
-from pypy.objspace.std.basestringtype import basestring_typedef
from pypy.objspace.std.register_all import register_all
@@ -310,7 +309,7 @@
# ____________________________________________________________
-str_typedef = StdTypeDef("str", basestring_typedef,
+str_typedef = StdTypeDef("bytes",
__new__ = gateway.interp2app(descr__new__),
__doc__ = '''str(object) -> string
diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -2,7 +2,6 @@
from pypy.interpreter import gateway
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.basestringtype import basestring_typedef
from pypy.rlib.runicode import str_decode_utf_8, str_decode_ascii,\
unicode_encode_utf_8, unicode_encode_ascii
@@ -358,7 +357,7 @@
# ____________________________________________________________
-unicode_typedef = StdTypeDef("unicode", basestring_typedef,
+unicode_typedef = StdTypeDef("str",
__new__ = gateway.interp2app(descr_new_),
__doc__ = '''unicode(string [, encoding[, errors]]) -> object
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit