Created
May 5, 2012 16:49
-
-
Save AlekSi/2603973 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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([]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reason: in RPython s[0] returns char, s[0:1] – string, they are different types.