Skip to content

Instantly share code, notes, and snippets.

@AlekSi
Created May 5, 2012 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlekSi/2603973 to your computer and use it in GitHub Desktop.
Save AlekSi/2603973 to your computer and use it in GitHub Desktop.
def f1(s):
# Python 2: ok
# Python 3: TypeError: ord() expected string of length 1, but int found (it returns int for binary string)
# RPython : ok
return ord(s[0])
def f2(s):
# Python 2: ok
# Python 3: ok
# RPython : Blocked block -- operation cannot succeed: v1 = ord(v0)
return ord(s[0:1])
def main(argv):
f1(b'a')
# f2(b'a')
return 0
def target(*args):
return main, None
if __name__ == "__main__":
main([])
@AlekSi
Copy link
Author

AlekSi commented May 5, 2012

Reason: in RPython s[0] returns char, s[0:1] – string, they are different types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment