Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This is a followup on my previous question, I am using the 2to3 tool as suggested by Senthil Kumaran

It seems to work well but it doesn't pick up this part:

raise LexError,("%s:%d: Rule '%s' returned an unknown token type '%s'" % (
    func.func_code.co_filename, func.func_code.co_firstlineno,
    func.__name__, newtok.type),lexdata[lexpos:])

What should this look like in 3.2 ?

EDIT: the changes from the answer below are good, 2to3 now seems to work ok. Howevery in the setup.py build I now get the error below, see my new question.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

The func_code attribute of functions has been renamed to __code__, so try

func.__code__.co_filename, func.__code__.co_firstlineno,

as the second line of your code snippet.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...