Skip to content
Permalink
Browse files

Merge pull request #536 from krekoten/string_new

Fixed String subclassing
  • Loading branch information
alex committed Mar 20, 2013
2 parents ac73dd9 + c11eeb3 commit cfd8a9b21db7b81c782b0dd5a1aa381a38853b4e

This file was deleted.

@@ -1,3 +1 @@
fails:String.new returns an instance of a subclass
fails:String.new is called on subclasses
fails:String.new returns a binary String
@@ -297,8 +297,8 @@ class W_StringObject(W_Object):
classdef = ClassDef("String", W_Object.classdef, filepath=__file__)
classdef.include_module(Comparable)

def __init__(self, space, storage, strategy):
W_Object.__init__(self, space)
def __init__(self, space, storage, strategy, klass=None):
W_Object.__init__(self, space, klass)
self.str_storage = storage
self.strategy = strategy

@@ -394,7 +394,9 @@ def tr_trans(self, space, source, replacement, squeeze):

@classdef.singleton_method("allocate")
def singleton_method_allocate(self, space, w_s=None):
return space.newstr_fromstr("")
strategy = space.fromcache(ConstantStringStrategy)
storage = strategy.erase("")
return W_StringObject(space, storage, strategy, self)

@classdef.method("initialize")
def method_initialize(self, space, w_s=None):

0 comments on commit cfd8a9b

Please sign in to comment.
You can’t perform that action at this time.