Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From said <a href="http://www.python.org/dev/peps/pep-0263/" rel="nofollow">PEP (0268)</a>:</p> <blockquote> <p>Python's tokenizer/compiler combo will need to be updated to work as follows:</p> <ol> <li><p>read the file</p></li> <li><p>decode it into Unicode assuming a fixed per-file encoding</p></li> <li><p>convert it into a UTF-8 byte string</p></li> <li><p>tokenize the UTF-8 content</p></li> <li><p>compile it, creating Unicode objects from the given Unicode data and creating string objects from the Unicode literal data by first reencoding the UTF-8 data into 8-bit string data using the given file encoding</p></li> </ol> </blockquote> <p>Indeed, if you check <code>Parser/tokenizer.c</code> in the Python source you'll find functions <a href="http://hg.python.org/cpython/file/bf5b974e7d32/Parser/tokenizer.c#l224" rel="nofollow"><code>get_coding_spec</code></a> and <a href="http://hg.python.org/cpython/file/bf5b974e7d32/Parser/tokenizer.c#l271" rel="nofollow"><code>check_coding_spec</code></a> which are responsible for finding this information on a line being examined in <a href="http://hg.python.org/cpython/file/bf5b974e7d32/Parser/tokenizer.c#l543" rel="nofollow"><code>decoding_fgets</code></a>.</p> <p>It doesn't look like this capability is being exposed anywhere to you as a python API (at least these specific functions aren't <code>Py</code> prefixed -, so your options are third party library and/or re-purposing these functions as an extension. I don't personally know of any third party libraries - I can't see this functionality in the standard library either.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload