Skip to content

Commit

Permalink
Fix for encode("ascii") called on a unichar.
Browse files Browse the repository at this point in the history
git-svn-id: http://codespeak.net/svn/pypy/trunk@76143 fd0d7bf2-dfb6-0310-8d31-b7ecfe96aada
  • Loading branch information
Armin Rigo committed Jul 12, 2010
1 parent ca792dd commit 6f90f97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pypy/rpython/rstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def rtype_method_encode(self, hop):
if not hop.args_s[1].is_constant():
raise TyperError("encoding must be constant")
encoding = hop.args_s[1].const
v_self = hop.inputarg(self.repr, 0)
v_self = hop.inputarg(self.lowleveltype, 0)
hop.exception_is_here()
if encoding == "ascii":
return hop.gendirectcall(self.ll_str, v_self)
Expand Down
6 changes: 6 additions & 0 deletions pypy/rpython/test/test_rstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,12 @@ def f(i):
return str(c[i])[0]
assert self.interpret(f, [1]) == "b"

def test_encode_char(self):
def f(i):
c = u"abc"
return c[i].encode("ascii")
assert self.ll_to_string(self.interpret(f, [0])) == "a"

def FIXME_test_str_to_pystringobj():
def f(n):
if n >= 0:
Expand Down

0 comments on commit 6f90f97

Please sign in to comment.