[issue2477] parser support for future import of unicode_strings

2008-03-24 Thread Neal Norwitz

New submission from Neal Norwitz <[EMAIL PROTECTED]>:

This is a patch that modifies the parser to allow getting the future
import flags into the AST.  There are 2 approaches that are embedded
within the patch.  Both approaches can be seen in Python/pythonrun.c.

1) update_flags_from_node() - this pulls the __future__ import out of
the parser nodes.  It is not complete, but should give an idea of how
this approach could be generalized.
2) Add APIS such as PyParser_ParseFileFlagsEx that returns the flags
from the parser

The first approach is somewhat fragile and kinda breaks encapsulation. 
It's nice that all the changes are internal and localized.

The second approach is probably a better long term solution, but adds
even more APIs where there are already too many.

--
components: Interpreter Core
files: uni-strs.diff
keywords: patch
messages: 64458
nosy: nnorwitz
priority: critical
severity: normal
status: open
title: parser support for future import of unicode_strings
versions: Python 2.6
Added file: http://bugs.python.org/file9844/uni-strs.diff

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

I'll check it out today.

--
assignee:  -> tiran
nosy: +tiran

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Eric Smith

Changes by Eric Smith <[EMAIL PROTECTED]>:


--
nosy: +eric.smith

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

I've carefully examined both version. I agree that
update_flags_from_node is too fragile. I haven't verified my theory but
I *think* the current code does neither support

  from __future__ import egg, spam

nor

  from __future__ import egg
  from __future__ import spam

The PyParser_ParseFileFlagsEx() is easier and more stable. I'll go with it.

By the way I also like your name "unicode_strings". Should we stay with
it or use my idea "unicode_literals"?

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Marc-Andre Lemburg

Marc-Andre Lemburg <[EMAIL PROTECTED]> added the comment:

The flag should be named "unicode_literals" since that what changes.
Unicode strings are already available in Python 2.x :-)

BTW: I'm not convinced that these future imports are all that useful -
the ratio between usefulness and added complexity leans a lot towards
the latter.

--
nosy: +lemburg

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

Working patch

I had to introduce yet another PyParser Ex method for string parsing. I
also renamed the future feature to "unicode_literals"

Added file: http://bugs.python.org/file9846/unicode_literals.patch

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Ralf Schmitt

Changes by Ralf Schmitt <[EMAIL PROTECTED]>:


--
nosy: +schmir

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Nick Coghlan

Nick Coghlan <[EMAIL PROTECTED]> added the comment:

The patch actually isn't all that complicated - the main structural
change to make it possible to process the strings correctly is
converting the parser functions to have treat the flags argument as an
I/O variable, rather than just an input. Other than that, there are just
some fairly straightforward updates to the compiler to take advantage of
the additional flag information now available from the parser.

Being able to write significant pieces of code that run on both 2.6 and
3.0 without modification will be a big win in my opinion. While 2to3
will still be a valuable migration tool, especially for one-way
migrations, it will be far far easier to support 2.6 and 3.0 in parallel
if that pseudo-compilation step isn't necessary.

Also Christian - the posted patch accidentally included your hack to
make the version info a bit more non-SVN checkout friendly.

--
nosy: +ncoghlan

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

> Also Christian - the posted patch accidentally included your hack to
make the version info a bit more non-SVN checkout friendly.

I'm still learning bzr. I just have figured out how to merge changes
from the upstream trunk into my branch. It's actually nice ...

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Christian Heimes

Changes by Christian Heimes <[EMAIL PROTECTED]>:


Removed file: http://bugs.python.org/file9846/unicode_literals.patch

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-25 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

Slightly better patch

* removed bzr hack
* simplified parsestr()
* updated NEWS

Added file: http://bugs.python.org/file9855/unicode_literals2.patch

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2477] parser support for future import of unicode_strings

2008-03-28 Thread Neal Norwitz

Neal Norwitz <[EMAIL PROTECTED]> added the comment:

Christian checked this in a few days ago in r61953 and a few other
revisions.

--
resolution:  -> accepted
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com