| ★ wanayoo — archive 1999 https://github.com/ipython/ipython/pull/2134/ | Nouvelle recherche | Portail wanayoo |
Test results for commit 360c5cd merged into master
Platform: linux2
Not available for testing: python2.6
IPython/external/pexpect/_pexpect.py
| ... | ... |
@@ -940,6 +940,8 @@ def next (self): # File-like object. |
| 940 | 940 |
raise StopIteration |
| 941 | 941 |
return result |
| 942 | 942 |
|
| 943 |
+ next = __next__ # File-like object. (Python 2). |
| 3 |
Alternatively we could treat this as:
This would make it more obvious what needs to be ripped out if Python 2 support was ever dropped... I think I'd side with doing that. I agree. I've made the changes and pushed a new commit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
|
|
|
bfroehle |
Apply 2to3 `next` fix.
…
Manually set `next = __next__` for Python 2 support. |
30e4a14
|
Test results for commit 30e4a14 merged into master
Platform: linux2
Not available for testing: python2.6
This looks OK to me. If no-one objects in about a day, we can merge it.
IPython/zmq/iostream.py
((6 lines not shown)) |
||
| 58 | 59 |
raise IOError('Read not supported on a write only stream.')
|
| 59 | 60 |
|
| 61 |
+ if not py3compat.PY3: |
|
| 62 |
+ next = __next__ |
|
| 63 |
+ |
|
| 1 |
Is there a good reason that this method is defined in a conditional, and not just
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
|
Ah, now I just saw the conversation above. I don't really agree with the decision, but I don't feel strongly, so I'll go with you guys. Also, Python 2.6 testing is the most important here before merge.
Test results for commit 30e4a14 merged into master
Platform: darwin
Not available for testing: python3.1
2.6 is happy, +1 to merge.
Merged - thanks.
Showing 1 unique commit by 1 author.
| Jul 13, 2012 | ||||
|---|---|---|---|---|
|
|
bfroehle |
Apply 2to3 `next` fix.
…
Manually set `next = __next__` for Python 2 support. |
30e4a14
|
|
Showing 7 changed files with 15 additions and 7 deletions. Show diff stats Hide diff stats
@@ -718,10 +718,10 @@ def python_func_kw_matches(self,text): |
||
| 718 | 718 |
isId = re.compile(r'\w+$').match |
| 719 | 719 |
while True: |
| 720 | 720 |
try: |
| 721 |
- ids.append(iterTokens.next())
|
|
| 721 |
+ ids.append(next(iterTokens))
|
|
| 722 | 722 |
if not isId(ids[-1]): |
| 723 | 723 |
ids.pop(); break |
| 724 |
- if not iterTokens.next() == '.':
|
|
| 724 |
+ if not next(iterTokens) == '.':
|
|
| 725 | 725 |
break |
| 726 | 726 |
except StopIteration: |
| 727 | 727 |
break |
@@ -930,7 +930,7 @@ def __iter__ (self): # File-like object. |
||
| 930 | 930 |
|
| 931 | 931 |
return self |
| 932 | 932 |
|
| 933 |
- def next (self): # File-like object.
|
|
| 933 |
+ def __next__ (self): # File-like object.
|
|
| 934 | 934 |
|
| 935 | 935 |
"""This is to support iterators over a file-like object. |
| 936 | 936 |
""" |
@@ -940,6 +940,9 @@ def next (self): # File-like object. |
||
| 940 | 940 |
raise StopIteration |
| 941 | 941 |
return result |
| 942 | 942 |
|
| 943 |
+ if not PY3: |
|
| 944 |
+ next = __next__ # File-like object. |
|
| 945 |
+ |
|
| 943 | 946 |
def readlines (self, sizehint = -1): # File-like object. |
| 944 | 947 |
|
| 945 | 948 |
"""This reads until EOF using readline() and returns a list containing |
@@ -174,7 +174,7 @@ def _get_format(self, token): |
||
| 174 | 174 |
def _get_format_from_document(self, token, document): |
| 175 | 175 |
""" Returns a QTextCharFormat for token by |
| 176 | 176 |
""" |
| 177 |
- code, html = self._formatter._format_lines([(token, u'dummy')]).next()
|
|
| 177 |
+ code, html = next(self._formatter._format_lines([(token, u'dummy')]))
|
|
| 178 | 178 |
self._document.setHtml(html) |
| 179 | 179 |
return QtGui.QTextCursor(self._document).charFormat() |
| 180 | 180 |
|
@@ -51,7 +51,7 @@ def run_parametric(self, result, testMethod): |
||
| 51 | 51 |
# Test execution |
| 52 | 52 |
ok = False |
| 53 | 53 |
try: |
| 54 |
- testgen.next()
|
|
| 54 |
+ next(testgen)
|
|
| 55 | 55 |
ok = True |
| 56 | 56 |
except StopIteration: |
| 57 | 57 |
# We stop the loop |
@@ -179,7 +179,7 @@ def arg_split(s, posix=False, strict=True): |
||
| 179 | 179 |
tokens = [] |
| 180 | 180 |
while True: |
| 181 | 181 |
try: |
| 182 |
- tokens.append(lex.next())
|
|
| 182 |
+ tokens.append(next(lex))
|
|
| 183 | 183 |
except StopIteration: |
| 184 | 184 |
break |
| 185 | 185 |
except ValueError: |
@@ -5,6 +5,7 @@ |
||
| 5 | 5 |
from session import extract_header, Message |
| 6 | 6 |
|
| 7 | 7 |
from IPython.utils import io, text, encoding |
| 8 |
+from IPython.utils import py3compat |
|
| 8 | 9 |
|
| 9 | 10 |
#----------------------------------------------------------------------------- |
| 10 | 11 |
# Globals |
@@ -54,9 +55,12 @@ def flush(self): |
||
| 54 | 55 |
def isatty(self): |
| 55 | 56 |
return False |
| 56 | 57 |
|
| 57 |
- def next(self):
|
|
| 58 |
+ def __next__(self):
|
|
| 58 | 59 |
raise IOError('Read not supported on a write only stream.')
|
| 59 | 60 |
|
| 61 |
+ if not py3compat.PY3: |
|
| 62 |
+ next = __next__ |
|
| 63 |
+ |
|
| 60 | 64 |
def read(self, size=-1): |
| 61 | 65 |
raise IOError('Read not supported on a write only stream.')
|
| 62 | 66 |
|
@@ -272,6 +272,7 @@ def run(self): |
||
| 272 | 272 |
'lib2to3.fixes.fix_except', |
| 273 | 273 |
'lib2to3.fixes.fix_apply', |
| 274 | 274 |
'lib2to3.fixes.fix_repr', |
| 275 |
+ 'lib2to3.fixes.fix_next', |
|
| 275 | 276 |
] |
| 276 | 277 |
from setuptools.command.build_py import build_py |
| 277 | 278 |
setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)}
|
Tip: You can add notes to lines in a file. Hover to the left of a line to make a note
| 1 |
Is there a good reason that this method is defined in a conditional, and not just
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
|
Continuing on the Python 2/3 compatibility (which I'll refer to as '2and3') from #2095 and #2100, I propose to include the changes from running
2to3 -f next:One small issue is the behavior of
next(x)on user defined classes:Consider
test_next.pyAnd run it in Python 2.7 and 3.2:
To work around this difference, I've just set
next = __next__manually after applying the 2to3 fix. This also maintains compatibility with any third party code which callsx.next().