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
Unicode bug in Itpl when expanding shell variables in syscalls with ! #822
Comments
Isn't it well established that Itpl just doesn't support unicode in the slightest? |
Right... I had people in front of me so it was really quick and I didn't have the bandwidth to recall that. One more reason to push on moving out of Itpl, then. Unicode in the filesystem is more and more common, so this will be more annoying to people as time goes on. I don't know if we'll manage to transition it by 0.12 though. |
Just to mention, the |
@fperez: Is the prompt manager stuff likely to get in for 0.12? If not, I can copy across the |
Let's see if we can find the time to resolve those. If we can make headway into the harder PRs we have before release, we won't need to. I'd like to tackle them one at a time over the next week, we'll see how it goes. |
Itpl is actually quite small, and it was easy to get it working, at least for this particular bug. If we do want to keep it, should I keep it str-only, or make it unicode-native, or just leave it like Thomas says, and move to EvalFormatter (losing '$' in the process). EvalFormatter is definitely much better (and more pythonic) code. But I have a feeling that the people who use the '$' expansion will be very sad to see it gone. Especially if we restore the long lost shell profile. |
I'd forgotten that itpl is the one that gives us $ expansion, and that is something that is definitely very useful, and that I've demoed multiple times to audiences in addition to using it personally quite regularly. So that's a good argument for keeping Itpl around then, even if we move to EvalFormatter for most of our internal use. In that case, making it unicode compliant seems like the right way to go, as that will ensure things work OK in py3. |
Making $name and $name.attr work should just be a few lines subclass of FullEvalFormatter, so if it allows us to drop ~300 lines of Itpl (which it seems we now need to maintain ourselves), I think it's worth doing. More complex expressions will need to be written as |
On Wed, Oct 19, 2011 at 5:10 AM, Thomas
+1. I think $n and $n.a are the two main use cases for this, so I'm all for it. |
Great - I'll get onto this either when the prompt manager stuff gets merged, |
On Wed, Oct 19, 2011 at 9:15 AM, Thomas
OK. I've been trying to get to the 'meaty' PRs, but the flow of |
Sounds good - I'll slow down on the small ones, I was just trying to clean out some of the easy 0.12 issues. Thomas, how were you thinking adding '$foo' support would work in FullEval? All the actual parsing in handled by the |
I should also note that when I was digging into this ( I do already have unicode itpl working ), I discovered a small related bug - os.system doesn't like unicode, so we have to make sure that we encode with unicode_to_str when we pass to it. |
On Wed, Oct 19, 2011 at 10:00 AM, Min RK
I wasn't trying to sound critical, BTW. It's awesome that you |
On 19 October 2011 18:00, Min RK <
Itpl does character by character processing, so you can have complex string.Formatter has an overridable .parse method, where this logic can go. |
okay, makes sense. |
On Wed, Oct 19, 2011 at 10:56 AM, Thomas
It's OK also b/c I think it improves readability. For a complex |
So am I correct in understanding that the official plan for this is for Thomas to add |
On Fri, Oct 21, 2011 at 2:23 PM, Min RK
At least moving over to FullEvalFormatter. I'd hold off on removing |
@takluyver, let me know if the test I added in 31ab23f causes any issues in py3. Thanks for the PR! |
Should a person have access to environment variables? E.g., I can't do
|
@stefanv Yes, they should, though the point of this is to allow |
Dollar formatter for ! shell calls. This uses a subclass of `FullEvalFormatter` for filling in variables in shell commands like `!echo $spam`, instead of Itpl. I've retained the `{foo}` style standard formatting for complex expressions, so it can be picked up by the more powerful built in parser. `$foo` works for names and attribute access. FullEvalFormatter now always outputs unicode, even if you gave it a bytes string. This avoids problems when you mix 8-bit non-ascii strings and unicode (which e.g. `StringIO.StringIO` suffers from). Closes ipython#822 (test was added in 31ab23f).
found this today during a presentation, dumping quickly...
The text was updated successfully, but these errors were encountered: