New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for #1688, traceback-unicode issue #1715
Conversation
@@ -69,7 +69,7 @@ | |||
# the file COPYING, distributed as part of this software. | |||
#***************************************************************************** | |||
|
|||
from __future__ import with_statement | |||
from __future__ import with_statement, unicode_literals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of with_statement
here - we already dropped Python 2.5 support, and it's native in 2.6+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thomas Kluyver skrev 2012-05-09 21:38:
We can get rid of
with_statement
here - we already dropped Python 2.5 support, and it's native in 2.6+.ok I'll remove it
We need to be a little bit careful with |
Test results for commit ca15c23 merged into master
Not available for testing: python2.6 |
For manual testing, three commands I'd like to check work:
The focus is on Python 2, since this shouldn't change anything for Python 3. Also, cycle through the three traceback modes using |
It all seems to be OK on Linux, with Python 2.7.3 and with 2.6.7. |
In magic_paste text is sent to colorize from the clipboard. What happens on non-windows platforms? Will clipboard_get return a str or unicode. If str what should I assume about encoding? |
I think some of the new functionality in This PR has also picked up a conflict with master, so we'll need to rebase it before we can merge. |
|
I've filed a Python issue for the problems with Tkinter clipboard_get(): http://bugs.python.org/issue14777 |
I'll look into it. I'm travelling so it will not be before sunday. 11 maj 2012 kl. 00:21 skrev Thomas Kluyver reply@reply.github.com:
|
Thomas Kluyver skrev 2012-05-11 00:21:
|
Thomas Kluyver skrev 2012-05-11 00:31:
I have added casts to unicode for clipboard_get on Linux and OSX. I used |
How do I use the demo mode? In the docs there is a reference to docs/examples/core/demo-exercizer.py but that file seems to be gone. I think demo mode is broken with this PR as is but I do not know how to use it. |
Is demo mode the same thing as this? http://ipython.org/ipython-doc/dev/interactive/reference.html#interactive-demos-with-ipython |
@@ -14,6 +14,7 @@ | |||
#----------------------------------------------------------------------------- | |||
# Imports | |||
#----------------------------------------------------------------------------- | |||
import re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is added with no other changes to the file - I guess it's a leftover?
Thomas Kluyver skrev 2012-05-15 22:16:
yes that description should be enough. I found this one |
I've got the problem with Tkinter fixed for Python 3.3/3.2.4/2.7.4. I'm now a CPython contributor! :-) |
I just rebased from master 2caea25 after the magics PR. |
The magics refactoring broke several magic commands (pdef, pdoc, psource, pfile) commit a71d86a fixes this |
@@ -361,9 +373,8 @@ def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): | |||
and tpl_line_em \ | |||
or tpl_line | |||
ret.append(self.__format_line(linetpl, filename, | |||
start + 1 + i, line, | |||
start + 1 + i, line.decode(encoding, errors="replace"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about this? I expect in Python 3, line will already be str
, so decoding it again will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thomas Kluyver skrev 2012-05-31 21:46:
@@ -361,9 +373,8 @@ def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3):
and tpl_line_em
or tpl_line
ret.append(self.__format_line(linetpl, filename,
start + 1 + i, line,
start + 1 + i, line.decode(encoding, errors="replace"),
Are you sure about this? I expect in Python 3, line will already be
str
, so decoding it again will fail.fixed in 98fd6f8
Test results for commit a71d86a merged into master
Not available for testing: python2.6 |
Hey guys, just touching bases on this. How far do you think we are from merging it? We have so many PRs in flight that I'm a bit worried and don't want to create multiple conflicts everywhere... We also need to begin thinking about 0.13 sometime soon... |
@@ -351,6 +367,10 @@ def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): | |||
|
|||
start = lineno - 1 - context//2 | |||
lines = linecache.getlines(filename) | |||
try: | |||
encoding, _ = openpy.detect_encoding(_readline(lines)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect Python 3 linecache will take care of decoding lines
for us, and this will go wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test run appears to confirm my suspicion.
fix to handle the case when len(lines)<2
when calling %run -d the filename available for pdb is <string> which is not a proper filename. %run now adds a _exec_lines attribute containing the correct filename.
Use read_py_file to get python source in unicode format.
Fix to interpret str docstrings with the encoding of the sourcefile.
Fix to interpret source of object with the encoding of the sourcefile.
Most files in linecache are stored with the filename as a bytestring (py2.x). When calling getlines with a unicode filename there will be implicit conversions using ascii that fails. This is avoided by an explicit conversion using the filesystem encoding before calling getlines.
For instance Windows IO error messages are localized and may contain non-ascii chracters.
OK, we reviewed this at Euroscipy and fixed things up. I think it should go in so we can start finding any odd consequences. @jstenar @fperez @ellisonbg @minrk @bfroehle , I'll merge this tomorrow if no-one objects. |
Fix for #1688, traceback-unicode issue
Add git-mpr, to merge PR(s) from github just by number(s). Inspired by git-mrb and test_pr, I thougth it would be usefull to be able to merge PR only by giving their number. Hence `git merge-pull-request`or `git-mpr`. usage: ```bash $ git mpr -h ~/ipython/tools usage: git-mpr [-h] [-l | -a | -m [pr-number [pr-number ...]]] Merge (one|many) github pull request by their number. If pull request can't be merge as is, cancel merge, and continue to the next if any. optional arguments: -h, --help show this help message and exit -l, --list list PR, their number and their mergeability -a, --merge-all try to merge as many PR as possible, one by one -m [pr-number [pr-number ...]], --merge [pr-number [pr-number ...]] The pull request numbers ``` examples : ```bash $ git mpr --list * ipython#1758 [√]: test_pr, fallback on http if git protocol fail, and SSL errors... * ipython#1755 [√]: test for pygments before running qt tests * ipython#1715 [√]: Fix for ipython#1688, traceback-unicode issue [...] * ipython#1493 [√]: Selenium web tests proof-of-concept * ipython#1471 [ ]: simplify IPython.parallel connections and enable Controller Resume * ipython#1343 [ ]: Add prototype shutdown button to Notebook dashboard * ipython#1285 [√]: Implementation of grepping the input history using several patterns * ipython#1215 [√]: updated %quickref to show short-hand for %sc and %sx ``` PR number, mergeability and title Quite slow, as it does 1 api call by PR, since api does not give mergeability anymore if you ask for the list of all PRs at once. merge one or more PR (skip the ones with conflict and present a nice list to copy and past to do it by hand) ```bash $ git mpr --merge [pr-number [pr-number ...]]] [...] ************************************************************************************* the following branch have not been merged automatically, considere doing it by hand : PR 1630: git pull https://github.com/minrk/ipython.git mergekernel PR 1343: git pull https://github.com/takluyver/ipython.git notebook-shutdown PR 1715: git pull https://github.com/jstenar/ipython.git ultratb-pycolorize-unicode PR 1732: git pull https://github.com/fperez/ipython.git cellmagics PR 1471: git pull https://github.com/minrk/ipython.git connection PR 1674: git pull https://github.com/mdboom/ipython.git notebook-carriage-return ************************************************************************************* ``` And last, ``` git mpr --merge-all ``` That is pretty self explainatory
Fix for ipython#1688, traceback-unicode issue
PR to work on a fix for #1688. Right now there is one commit with a quick and dirty solution using
unicode_literals
from__future__
and two casts to unicode. No new test failures were noted.There are more locations where we will have errors. Any calls to pycolorize needs to make sure to use only unicode. One example is docstring printing using ?
I could add casts in pycolorize instead, should I do that?