On 11/3/07, Christian Heimes <[EMAIL PROTECTED]> wrote:
> Alexandre Vassalotti wrote:
> >> Modified: python/branches/py3k-pep3137/Lib/string.py
> >> ==============================================================================
> >> --- python/branches/py3k-pep3137/Lib/string.py  (original)
> >> +++ python/branches/py3k-pep3137/Lib/string.py  Fri Nov  2 16:59:04 2007
> >> @@ -53,7 +53,7 @@
> >>          raise ValueError("maketrans arguments must have same length")
> >>      if not (isinstance(frm, bytes) and isinstance(to, bytes)):
> >>          raise TypeError("maketrans arguments must be bytes objects")
> >> -    L = bytes(range(256))
> >> +    L = buffer(range(256))
> >>      for i, c in enumerate(frm):
> >>          L[c] = to[i]
> >>      return L
> >>
> >
> > Why string.maketrans() was changed to return a buffer object?
>
> The return type was a PyBytes instance before the grant renaming, too. I
> guess you are right. It should return a bytes object.

Hm, but the string module is about *text strings*, not bytes. For text
strings, we don't need maketrans (the new str.translate takes a dict
argument (*)). Maybe it should be a static method on the bytes type
(and also on the buffer type for symmetry)?

(*) Hm, maybe a maketrans() that takes two strings and returns a dict
would be useful, it's a bit more compact than a dict literal.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to