Author: David Schneider <[email protected]>
Branch:
Changeset: r46:495612e30422
Date: 2011-09-23 09:28 +0200
http://bitbucket.org/pypy/lang-io/changeset/495612e30422/
Log: fix sequence asCapitalized to only capitalize first char and leave
the rest unchanged
diff --git a/io/sequence.py b/io/sequence.py
--- a/io/sequence.py
+++ b/io/sequence.py
@@ -9,7 +9,7 @@
@register_method('Sequence', 'asCapitalized')
def sequence_as_capitalized(space, w_target, w_message, w_context):
- # c/p from pypy/objspace/std/stringobject.py
+ # based on pypy/objspace/std/stringobject.py
input = w_target.value
buffer = [' '] * len(input)
if len(input) > 0:
@@ -22,11 +22,7 @@
for i in range(1, len(input)):
ch = input[i]
- if ch.isupper():
- o = ord(ch) + 32
- buffer[i] = chr(o)
- else:
- buffer[i] = ch
+ buffer[i] = ch
s = space.w_sequence.clone()
s.value = "".join(buffer)
diff --git a/io/test/test_sequence.py b/io/test/test_sequence.py
--- a/io/test/test_sequence.py
+++ b/io/test/test_sequence.py
@@ -16,3 +16,9 @@
def test_sequence_as_capitalized():
inp = '"asdf qerttz" asCapitalized'
+ res, space = interpret(inp)
+ assert res.value == "Asdf qerttz"
+
+ inp = '"fooBar" asCapitalized'
+ res, space = interpret(inp)
+ assert res.value == "FooBar"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit