Re: [Python-Dev] Improving the reading part of REPL

2015-11-20 Thread Adam Bartoš
Another issue with the current implementation is
http://bugs.python.org/issue24829. Even if I fix my Python environment by
win_unicode_console so >>> "α" really results in "α" rather than "?", the
feature vanishes when I try to redirect stdout.

On Thu, Nov 19, 2015 at 10:50 PM, Adam Bartoš  wrote:

> It seems that there will be some refactoring of the tokenizer code.
> Regarding this, I'd like to recall my proposal on readline hooks. It would
> be nice if char* based PyOS_Readline API was replaced by a Python str based
> hook customizable by Python code. I propose to add function
> sys.readlinehook accepting optional prompt and returning a line read
> interactively from a user. There would also be sys.__readlinehook__
> containing the original value of sys.readlinehook (similarly to
> sys.(__)displayhook(__), sys.(__)excepthook(__) and
> sys.(__)std(in/out/err)(__)).
>
> Currently, the input is read from C stdin even if sys.stdin is changed
> (see http://bugs.python.org/issue17620). This complicates fixing
> http://bugs.python.org/issue1602 – the standard sys.std* streams are not
> capable of communicating in Unicode with Windows console, and replacing the
> streams with custom ones is not enough – one has also to install a custom
> readline hook, which is currently complicated. And even after installing a
> custom readine hook one finds out that Python tokenizer cannot handle
> UTF-16, so he has to wrap the custom stream objects just to let their
> encoding attribute have a different value, because readlinehook currently
> returns char* rather than a Python string. For more details see the
> documentation of my package: https://github.com/Drekin/win-unicode-console
> .
>
> The pyreadline package also sets up a custom readline so it would benefit
> if doing so would be easier. Moreover, the two consumers of PyOS_Readline
> API – the input function and the tokenizer – assume a different encoding of
> the bytes returned by the readlinehook. Effectively, one assumes
> sys.stdout.encoding and the other sys.stdin.encoding, so if these two are
> different, there is no way to implement a correct readline hook.
>
> If sys.readlinehook was added, the builting input function would be just a
> thin wrapper over sys.readlinehook removing the newline character and
> turning no input into EOFError. I thing that the best default value for
> sys.readlinehook on Windows would be stdio_readline – just write the prompt
> to sys.stdout and read a line from sys.stdin. On Linux, the default
> implementation would call GNU readline if it is available and sys.stdin and
> sys.stdout are standard TTYs (the check present in the current
> implementation of the input function), and it would call stdio_readline
> otherwise.
>
> Regards, Adam Bartoš
>
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] nested try..except bug in generators

2015-11-20 Thread Yury Selivanov

Hi,

For anyone interested in tickling the low-level CPython
internals (in this case eval loop and generators
implementations), here's an interesting bug:
http://bugs.python.org/issue25612.

I have a patch that fixes it, but I'm not sure that it's
correct, and I desperately need someone to review it.

While debugging the issue, I found another oddity:

class MainError(Exception): pass
class SubError(Exception): pass

def main():
try:
raise MainError()
except MainError:
yield

coro = main()
coro.send(None)
coro.throw(SubError())

On the last line of the above snippet, SubError will
propagate.  However, it won't have it's __context__ set
to MainError.  Martin Panter suggests that it's not a bug,
and after giving this some thought, I now don't think it's
a bug too -- SubError was instantiated outside of MainError
from a code location where there was no error.  Thoughts?
Here's a separate issue for the __context__ bug/feature:
http://bugs.python.org/issue25683

Thanks,
Yury
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Summary of Python tracker Issues

2015-11-20 Thread Python tracker

ACTIVITY SUMMARY (2015-11-13 - 2015-11-20)
Python tracker at http://bugs.python.org/

To view or respond to any of the issues listed below, click on the issue.
Do NOT respond to this message.

Issues counts and deltas:
  open5260 (+28)
  closed 32181 (+38)
  total  37441 (+66)

Open issues with patches: 2311 


Issues opened (51)
==

#25589: test_ascii_formatd fails on Mac when built with Intel compiler
http://bugs.python.org/issue25589  reopened by christopher.hogan

#25622: Enable ctypes.test.test_values.Win_ValuesTestCase for non-Wind
http://bugs.python.org/issue25622  opened by martin.panter

#25623: Keep the link to Python implementation of OrderedDict
http://bugs.python.org/issue25623  opened by serhiy.storchaka

#25624: shutil.make_archive makes invalid directory entries
http://bugs.python.org/issue25624  opened by gumblex

#25625: "chdir" Contex manager for pathlib
http://bugs.python.org/issue25625  opened by Jáchym Barvínek

#25626: Gzip fails for file over 2**32 bytes
http://bugs.python.org/issue25626  opened by Ben Cipollini

#25627: distutils : file "bdist_rpm.py" does not quote filenames when 
http://bugs.python.org/issue25627  opened by TheRegRunner

#25628: Make namedtuple "verbose" and "rename" parameters into keyword
http://bugs.python.org/issue25628  opened by rhettinger

#25631: Segmentation fault with invalid Unicode command-line arguments
http://bugs.python.org/issue25631  opened by itaibn

#25632: Document BUILD_*_UNPACK opcodes
http://bugs.python.org/issue25632  opened by Antony.Lee

#25633: The documentation for urllib.request should mention http.clien
http://bugs.python.org/issue25633  opened by jon orebro

#25635: urllib2 cannot fully read FTP file
http://bugs.python.org/issue25635  opened by keakon

#25636: Let launcher autoselect best 32-bit Python on 64-bit system
http://bugs.python.org/issue25636  opened by Christian.Ullrich

#25637: Move non-collections-related ABCs out of collections.abc
http://bugs.python.org/issue25637  opened by brett.cannon

#25638: Verify the etree_parse and etree_iterparse benchmarks are work
http://bugs.python.org/issue25638  opened by brett.cannon

#25639: open 'PhysicalDriveN' on windows fails (since python 3.5) with
http://bugs.python.org/issue25639  opened by rokozh

#25640: EmailMessage should throw an error if policy is set to compat3
http://bugs.python.org/issue25640  opened by Matthieu Pepin

#25641: urllib/request.py/getproxies_environment() throws "dictionary 
http://bugs.python.org/issue25641  opened by alphalfalfa

#25642: Setting maxsize breaks asyncio.JoinableQueue/Queue
http://bugs.python.org/issue25642  opened by Chris Seto

#25643: Python tokenizer rewriting
http://bugs.python.org/issue25643  opened by serhiy.storchaka

#25644: Unable to open IDLE on Windows 10 with Python 2.7.10
http://bugs.python.org/issue25644  opened by jatanig

#25646: Distutils and Windows SDK 7.1
http://bugs.python.org/issue25646  opened by JGoutin

#25647: Return of asyncio.coroutine from asyncio.coroutine doesn't wor
http://bugs.python.org/issue25647  opened by vrutsky

#25649: Come up with a good way to handle module aliasing
http://bugs.python.org/issue25649  opened by brett.cannon

#25650: Mismatching documentation <=> behaviour for typing.Any
http://bugs.python.org/issue25650  opened by ebarry

#25651: Confusing output for TestCase.subTest(0)
http://bugs.python.org/issue25651  opened by ezio.melotti

#25652: collections.UserString.__rmod__() raises NameError
http://bugs.python.org/issue25652  opened by Jonathan Goble

#25653: ctypes+callbacks+fork+selinux = crash
http://bugs.python.org/issue25653  opened by arigo

#25654: test_multiprocessing_spawn ResourceWarning with -Werror
http://bugs.python.org/issue25654  opened by martin.panter

#25655: Python errors related to failures loading DLL's lack informati
http://bugs.python.org/issue25655  opened by never-eat-yellow-snow

#25656: multiprocessing.dummy: pool.map hangs on empty list
http://bugs.python.org/issue25656  opened by tomer70

#25657: virtualenv's activate does not update LD_LIBRARY_PATH
http://bugs.python.org/issue25657  opened by serge-sans-paille

#25658: PyThread assumes pthread_key_t is an integer, which is against
http://bugs.python.org/issue25658  opened by EdSchouten

#25659: ctypes.Array.from_buffer segmentation fault when trying to cre
http://bugs.python.org/issue25659  opened by spear...@gmail.com

#25660: tabs don't work correctly in python repl
http://bugs.python.org/issue25660  opened by yselivanov

#25661: tokenize.untokenize does not maintain the order of tabbed inde
http://bugs.python.org/issue25661  opened by Blake Hilliard

#25663: Make rlcompleter avoid duplicate global names
http://bugs.python.org/issue25663  opened by martin.panter

#25664: Unexpected UnicodeDecodeError in logging module
http://bugs.python.org/issue25664  opened by zephor

#25666: Python unexpectedly ignores a signal after fork
http://bugs.python.org/issue25666  opened by jon orebro

#25