[issue12675] tokenize module happily tokenizes code with syntax errors

2011-08-05 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Terry: agreed. Does anyone actually use this module? Does anyone know what the design goals are for tokenize? If someone can tell me, I'll do my best to make it meet them. Meanwhile, here's another bug. Each character of trailing whitespace

[issue12691] tokenize.untokenize is broken

2011-08-05 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Please find attached a patch containing four bug fixes for untokenize(): * untokenize() now always returns a bytes object, defaulting to UTF-8 if no ENCODING token is found (previously it returned a string in this case). * In compatibility

[issue12700] test_faulthandler fails on Mac OS X Lion

2011-08-05 Thread Gareth Rees
New submission from Gareth Rees g...@garethrees.org: On Mac OS 10.7, test_faulthandler fails. See test output below. It looks as though the tests may be at fault in expecting to see (?:Segmentation fault|Bus error) instead of (?:Segmentation fault|Bus error|Illegal instruction

[issue12691] tokenize.untokenize is broken

2011-08-05 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Thanks Ezio for the review. I've made all the changes you requested, (except for the re-ordering of paragraphs in the documentation, which I don't want to do because that would lead to the round-trip property being mentioned before it's

[issue12675] tokenize module happily tokenizes code with syntax errors

2011-08-04 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: I'm having a look to see if I can make tokenize.py better match the real tokenizer, but I need some feedback on a couple of design decisions. First, how to handle tokenization errors? There are three possibilities: 1. Generate an ERRORTOKEN

[issue12675] tokenize module happily tokenizes code with syntax errors

2011-08-04 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Having looked at some of the consumers of the tokenize module, I don't think my proposed solutions will work. It seems to be the case that the resynchronization behaviour of tokenize.py is important for consumers that are using

[issue12675] tokenize module happily tokenizes code with syntax errors

2011-08-04 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Ah ... TokenInfo is a *subclass* of namedtuple, so I can add extra properties to it without breaking consumers that expect it to be a 5-tuple. -- ___ Python tracker rep...@bugs.python.org http

[issue12691] tokenize.untokenize is broken

2011-08-04 Thread Gareth Rees
New submission from Gareth Rees g...@garethrees.org: tokenize.untokenize is completely broken. Python 3.2.1 (default, Jul 19 2011, 00:09:43) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type help, copyright, credits or license for more information. import tokenize, io

[issue12691] tokenize.untokenize is broken

2011-08-04 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: See my last paragraph: I propose to deliver a single patch that fixes both this bug and issue12675. I hope this is OK. (If you prefer, I'll try to split the patch in two.) I just noticed another bug in untokenize(): in compatibility mode

[issue12675] tokenize module happily tokenizes code with syntax errors

2011-08-01 Thread Gareth Rees
New submission from Gareth Rees g...@garethrees.org: The tokenize module is happy to tokenize Python source code that the real tokenizer would reject. Pretty much any instance where tokenizer.c returns ERRORTOKEN will illustrate this feature. Here are some examples: Python 3.3.0a0

[issue12675] tokenize module happily tokenizes code with syntax errors

2011-08-01 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: These errors are generated directly by the tokenizer. In tokenizer.c, the tokenizer generates ERRORTOKEN when it encounters something it can't tokenize. This causes parsetok() in parsetok.c to stop tokenizing and return an error

[issue12514] timeit disables garbage collection if timed code raises an exception

2011-07-07 Thread Gareth Rees
New submission from Gareth Rees g...@garethrees.org: If you call timeit.timeit and the timed code raises an exception, then garbage collection is disabled. I have verified this in Python 2.7 and 3.2. Here's an interaction with Python 3.2: Python 3.2 (r32:88445, Jul 7 2011, 15:52:49

[issue12514] timeit disables garbage collection if timed code raises an exception

2011-07-07 Thread Gareth Rees
Gareth Rees g...@garethrees.org added the comment: Patch attached. -- keywords: +patch Added file: http://bugs.python.org/file22605/issue12514.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12514

<    1   2