Esempio n. 1
0
def format__Unicode_ANY(space, w_unicode, w_format_spec):
    if not space.isinstance_w(w_format_spec, space.w_unicode):
        w_format_spec = space.call_function(space.w_unicode, w_format_spec)
    from pypy.objspace.std.unicodetype import unicode_from_object
    w_unicode = unicode_from_object(space, w_unicode)
    spec = space.unicode_w(w_format_spec)
    formatter = newformat.unicode_formatter(space, spec)
    return formatter.format_string(space.unicode_w(w_unicode))
Esempio n. 2
0
    def descr__new__unicode_box(space, w_subtype, w_arg):
        from pypy.module.micronumpy.interp_dtype import new_unicode_dtype

        arg = space.unicode_w(unicode_from_object(space, w_arg))
        # XXX size computations, we need tests anyway
        arr = VoidBoxStorage(len(arg), new_unicode_dtype(space, len(arg)))
        # XXX not this way, we need store
        #for i in range(len(arg)):
        #    arr.storage[i] = arg[i]
        return W_UnicodeBox(arr, 0, arr.dtype)
Esempio n. 3
0
    def descr__new__unicode_box(space, w_subtype, w_arg):
        from pypy.module.micronumpy.interp_numarray import W_NDimArray
        from pypy.module.micronumpy.interp_dtype import new_unicode_dtype

        arg = space.unicode_w(unicode_from_object(space, w_arg))
        arr = W_NDimArray([1], new_unicode_dtype(space, len(arg)))
        # XXX not this way, we need store
        # for i in range(len(arg)):
        #    arr.storage[i] = arg[i]
        return W_UnicodeBox(arr, 0, arr.dtype)
Esempio n. 4
0
    def descr__new__unicode_box(space, w_subtype, w_arg):
        from pypy.module.micronumpy.interp_numarray import W_NDimArray
        from pypy.module.micronumpy.interp_dtype import new_unicode_dtype

        arg = space.unicode_w(unicode_from_object(space, w_arg))
        arr = W_NDimArray([1], new_unicode_dtype(space, len(arg)))
        # XXX not this way, we need store
        #for i in range(len(arg)):
        #    arr.storage[i] = arg[i]
        return W_UnicodeBox(arr, 0, arr.dtype)
Esempio n. 5
0
    def descr__new__unicode_box(space, w_subtype, w_arg):
        raise OperationError(space.w_NotImplementedError, space.wrap("Unicode is not supported yet"))

        from pypy.module.micronumpy.interp_dtype import new_unicode_dtype

        arg = space.unicode_w(unicode_from_object(space, w_arg))
        # XXX size computations, we need tests anyway
        arr = VoidBoxStorage(len(arg), new_unicode_dtype(space, len(arg)))
        # XXX not this way, we need store
        #for i in range(len(arg)):
        #    arr.storage[i] = arg[i]
        return W_UnicodeBox(arr, 0, arr.dtype)
Esempio n. 6
0
    def descr__new__unicode_box(space, w_subtype, w_arg):
        raise OperationError(space.w_NotImplementedError,
                             space.wrap("Unicode is not supported yet"))

        from pypy.module.micronumpy.interp_dtype import new_unicode_dtype

        arg = space.unicode_w(unicode_from_object(space, w_arg))
        # XXX size computations, we need tests anyway
        arr = VoidBoxStorage(len(arg), new_unicode_dtype(space, len(arg)))
        # XXX not this way, we need store
        #for i in range(len(arg)):
        #    arr.storage[i] = arg[i]
        return W_UnicodeBox(arr, 0, arr.dtype)
Esempio n. 7
0
 def fmt_s(self, w_value):
     space = self.space
     got_unicode = space.isinstance_w(w_value, space.w_unicode)
     if not do_unicode:
         if got_unicode:
             raise NeedUnicodeFormattingError
         s = self.string_formatting(w_value)
     else:
         if not got_unicode:
             w_value = space.call_function(space.w_unicode, w_value)
         else:
             w_value = unicode_from_object(space, w_value)
         s = space.unicode_w(w_value)
     self.std_wp(s)
Esempio n. 8
0
 def fmt_s(self, w_value):
     space = self.space
     got_unicode = space.isinstance_w(w_value,
                                                  space.w_unicode)
     if not do_unicode:
         if got_unicode:
             raise NeedUnicodeFormattingError
         s = self.string_formatting(w_value)
     else:
         if not got_unicode:
             w_value = space.call_function(space.w_unicode, w_value)
         else:
             w_value = unicode_from_object(space, w_value)
         s = space.unicode_w(w_value)
     self.std_wp(s)