Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(15)

Side by Side Diff: Lib/idlelib/IOBinding.py

Issue 26581: Double coding cookie
Patch Set: Created 4 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/lib2to3/pgen2/tokenize.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import codecs 1 import codecs
2 from codecs import BOM_UTF8 2 from codecs import BOM_UTF8
3 import os 3 import os
4 import re 4 import re
5 import shlex 5 import shlex
6 import sys 6 import sys
7 import tempfile 7 import tempfile
8 8
9 import tkinter.filedialog as tkFileDialog 9 import tkinter.filedialog as tkFileDialog
10 import tkinter.messagebox as tkMessageBox 10 import tkinter.messagebox as tkMessageBox
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 locale_encoding = 'ascii' 55 locale_encoding = 'ascii'
56 codecs.lookup(locale_encoding) 56 codecs.lookup(locale_encoding)
57 except (ValueError, LookupError): 57 except (ValueError, LookupError):
58 pass 58 pass
59 59
60 locale_encoding = locale_encoding.lower() 60 locale_encoding = locale_encoding.lower()
61 61
62 encoding = locale_encoding ### KBK 07Sep07 This is used all over IDLE, check! 62 encoding = locale_encoding ### KBK 07Sep07 This is used all over IDLE, check!
63 ### 'encoding' is used below in encode(), check! 63 ### 'encoding' is used below in encode(), check!
64 64
65 coding_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)', re.ASCII) 65 coding_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
66 blank_re = re.compile(r'^[ \t\f]*(?:[#\r\n]|$)', re.ASCII) 66 blank_re = re.compile(r'^[ \t\f]*(?:[#\r\n]|$)', re.ASCII)
67 67
68 def coding_spec(data): 68 def coding_spec(data):
69 """Return the encoding declaration according to PEP 263. 69 """Return the encoding declaration according to PEP 263.
70 70
71 When checking encoded data, only the first two lines should be passed 71 When checking encoded data, only the first two lines should be passed
72 in to avoid a UnicodeDecodeError if the rest of the data is not unicode. 72 in to avoid a UnicodeDecodeError if the rest of the data is not unicode.
73 The first two lines would contain the encoding specification. 73 The first two lines would contain the encoding specification.
74 74
75 Raise a LookupError if the encoding is declared but unknown. 75 Raise a LookupError if the encoding is declared but unknown.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 text = Text(root) 557 text = Text(root)
558 text.pack() 558 text.pack()
559 text.focus_set() 559 text.focus_set()
560 editwin = MyEditWin(text) 560 editwin = MyEditWin(text)
561 IOBinding(editwin) 561 IOBinding(editwin)
562 562
563 if __name__ == "__main__": 563 if __name__ == "__main__":
564 from idlelib.idle_test.htest import run 564 from idlelib.idle_test.htest import run
565 run(_io_binding) 565 run(_io_binding)
OLDNEW
« no previous file with comments | « no previous file | Lib/lib2to3/pgen2/tokenize.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+