752 if not f.endswith('.t'): |
753 if not f.endswith('.t'): |
753 with open(f, 'rb') as src: |
754 with open(f, 'rb') as src: |
754 yield src.read(), modname, f, 0 |
755 yield src.read(), modname, f, 0 |
755 py = True |
756 py = True |
756 if py or f.endswith('.t'): |
757 if py or f.endswith('.t'): |
757 with open(f, 'r') as src: |
758 # Strictly speaking we should sniff for the magic header that denotes |
|
759 # Python source file encoding. But in reality we don't use anything |
|
760 # other than ASCII (mainly) and UTF-8 (in a few exceptions), so |
|
761 # simplicity is fine. |
|
762 with io.open(f, 'r', encoding='utf-8') as src: |
758 for script, modname, t, line in embedded(f, modname, src): |
763 for script, modname, t, line in embedded(f, modname, src): |
759 yield script, modname.encode('utf8'), t, line |
764 yield script, modname.encode('utf8'), t, line |
760 |
765 |
761 |
766 |
762 def main(argv): |
767 def main(argv): |