[Python-Dev] codeop: small details (Q); commit priv request (original) (raw)
Guido van Rossum guido@python.org
Thu, 15 May 2003 21:28:01 -0400
- Previous message: [Python-Dev] codeop: small details (Q); commit priv request
- Next message: [Python-Dev] Python 2.3b1 _XOPEN_SOURCE value from configure.in
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
1)
Python 2.3b1 (#40, Apr 25 2003, 19:06:24) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import codeop >>> codeop.compilecommand("",symbol="eval") Traceback (most recent call last): File "", line 1, in ? File "s:\transit\py23\lib\codeop.py", line 129, in compilecommand return maybecompile(compile, source, filename, symbol) File "s:\transit\py23\lib\codeop.py", line 106, in maybecompile raise SyntaxError, err1 File "", line 1 pass ^ SyntaxError: invalid syntax
the error is basically an artifact of the logic that enforces: compilecommand("",symbol="single") === compilecommand("pass",symbol="single") (this makes typing enter immediately after the prompt at a simulated shell a nop as expected) I would expect compilecommand("",symbol="eval") to return None, i.e. to simply signal an incomplete expression (that is what would happen if the code for "eval" case would avoid the cited logic).
Thanks for reporting this. I've fixed this by avoiding the change to "pass" when symbol == "eval".
2) symbol = "exec" is silently accepted but the documentation intentionally only refers to "exec" and "single" as valid values for symbol. Maybe a ValueError should be raised.
I don't know that that is intentional. I'd say that, like for the built-in compile(), the valid values for symbol should be "eval", "exec", and "single", and the docs ought to be updated (I didn't fix this).
Context: I was working on improving Jython codeop compatibility with CPython codeop.
Cool.
Btw, as considered here by Guido http://sourceforge.net/tracker/index.php?func=detail&aid=645404&groupid=5470&atid=305470 I would ask to have commit privileges for CPython
Barry has sworn you in by now. Welcome to the club!
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] codeop: small details (Q); commit priv request
- Next message: [Python-Dev] Python 2.3b1 _XOPEN_SOURCE value from configure.in
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]