Issue #20731: Properly position in source code files even if they · python/cpython@815b41b · GitHub
Skip to content

Commit 815b41b

Browse files
committed
Issue #20731: Properly position in source code files even if they
are opened in text mode. Patch by Serhiy Storchaka.
1 parent 9db1ab8 commit 815b41b

5 files changed

Lines changed: 29 additions & 3 deletions

File tree

.hgeol

Lines changed: 2 additions & 0 deletions

Lib/test/coding20731.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#coding:latin1
2+
3+
4+

Lib/test/test_coding.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22
from test.support import TESTFN, unlink, unload
3-
import importlib, os, sys
3+
import importlib, os, sys, subprocess
44

55
class CodingTest(unittest.TestCase):
66
def test_bad_coding(self):
@@ -58,6 +58,13 @@ def test_error_from_string(self):
5858
self.assertTrue(c.exception.args[0].startswith(expected),
5959
msg=c.exception.args[0])
6060

61+
def test_20731(self):
62+
sub = subprocess.Popen([sys.executable,
63+
os.path.join(os.path.dirname(__file__),
64+
'coding20731.py')],
65+
stderr=subprocess.PIPE)
66+
err = sub.communicate()[1]
67+
self.assertEquals(err, b'')
6168

6269
if __name__ == "__main__":
6370
unittest.main()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.3.5 release candidate 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #20731: Properly position in source code files even if they
14+
are opened in text mode. Patch by Serhiy Storchaka.
15+
1316
- Issue #19619: str.encode, bytes.decode and bytearray.decode now use an
1417
internal API to throw LookupError for known non-text encodings, rather
1518
than attempting the encoding or decoding operation and then throwing a

Parser/tokenizer.c

Lines changed: 12 additions & 2 deletions

0 commit comments

Comments
 (0)