On 8/31/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > >> Yuck, yuck about the source file encoding part. Also, there is no way > >> to tell that a particular argument was passed a literal.
> > There is when compiling to bytecode; it goes in co_consts. > >> The very > >> definition of "this was a literal" is iffy -- is x a literal when > >> passed to f below? > >> x = "abc" > >> f(x) > > No, it isn't. > By that definition, bytes never receives a constant. To go back to the original motivation x.split(":") # a constant, currently fails in Py3K x.split(b":") # mechanical replacement for x.split(":") sep=":" x.split(sep) # annoying but less important failure I would prefer that x.split(":") work. If that happens because bytes.split does the conversion for me (so that x.split(sep) also works), then great. But I realize that would require an assumption about the proper encoding. If it works because the bytecode compiler changes x.split(":") into the moral equivalent of try: x.split(":") except StrNotBytesError: x.split(b":") that is good enough. And for constants which appear as string literals in the code (token stringliteral), the proper encoding is known. -jJ _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com