Skip to content
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

conform to pep 3110 #2064

Merged
merged 4 commits into from Jul 4, 2012
Merged

conform to pep 3110 #2064

merged 4 commits into from Jul 4, 2012

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented Jun 30, 2012

brutally replace all exeption <type>, <name>: by
exception <type> as <name> :

exception <type>, <type> : should not be present anywhere in the code
anymore, or should be present with explicit tuple as
exception (<type>, <type>) :

see also #2061

brutally replace all `exeption <type>, <name>:` by
`exception <type> as <name> :`

`exception <type>, <type> :` should not be present anywhere in the code
anymore, or should be present with explicit tuple as
`exception (<type>, <type>)`
@fperez
Copy link
Member

fperez commented Jun 30, 2012

I think these are all good, but let's run a test_pr just to be safe...

@Carreau
Copy link
Member Author

Carreau commented Jul 1, 2012

Test results for commit 28b538a merged into master
Platform: darwin

  • python2.6: OK
  • python2.7: OK (libraries not available: cython oct2py pymongo rpy2 wx wx.aui)

Not available for testing: python3.1, python3.2

@Carreau
Copy link
Member Author

Carreau commented Jul 1, 2012

This make me think, there is a lot a "fixes" that 2to3 can apply independently to the all source tree and that will still be python2.x compatible.

Do we want to start applying them to have a smoother transition to a fully dirrectly python3 compatible version of IPython ?

I think the hardest part will be the u'strings' that are invalid python 3.1/3.2 but will be understood in python 3.3.

[edit :]
see https://github.com/Carreau/ipython/compare/2to3compat

2to3 makes a better job than regexp
@fperez
Copy link
Member

fperez commented Jul 1, 2012

On Sun, Jul 1, 2012 at 9:13 AM, Bussonnier Matthias
reply@reply.github.com
wrote:

Do we want to start applying them to have a smoother transition to a fully dirrectly python3 compatible version of IPython ?

In principle I agree with you, but I'd like to hear @takluyver's
opinion on this, since he actually uses py3 daily (I don't) and he's
sort of our py3 overlord.

@takluyver
Copy link
Member

I like this approach - I find except Exception as e much more readable than the old style. We could also skip the relevant 2to3 fixer during installation (they can be disabled individually, as seen here).

I've also been meaning to find all the files which use the ugly print >>foo syntax, and sprinkle some __future__ on them.

@Carreau
Copy link
Member Author

Carreau commented Jul 3, 2012

let's see this one as a first step.
I'll add a commit that disable exceptions in 2to3 and make another PR with what i've done so far tomorrow.

@takluyver
Copy link
Member

It looks like it's called except - the list is here.

this should allow a more compatible codebase between python 2.x and 3.x
@Carreau
Copy link
Member Author

Carreau commented Jul 4, 2012

skip except in setup.py for python3.
My python 3.2 keep trying to import nose from 2.7 site-package, so test_pr fail to test for python 3.x so if SO can run test_pr for my on python 3...

@Carreau
Copy link
Member Author

Carreau commented Jul 4, 2012

Test results for commit 1c49f84 merged into master
Platform: darwin

  • python2.6: OK
  • python2.7: OK (libraries not available: cython oct2py pymongo rpy2 wx wx.aui)

Not available for testing: python3.1, python3.2

@@ -234,6 +234,12 @@ def cleanup():

if PY3:
setuptools_extra_args['use_2to3'] = True
# we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code
# so we explicitely disable some 2to3 fixes to be sure we ain't forgetting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'explicitly'. Also, "ain't" is colloquial - we should use "aren't", so that it's clear to people who're less familiar with English.

@takluyver
Copy link
Member

Test results for commit 1c49f84 merged into master
Platform: linux2

  • python2.7: OK (libraries not available: oct2py pymongo tornado wx wx.aui)
  • python3.2: OK (libraries not available: oct2py pymongo wx wx.aui)

Not available for testing: python2.6, python3.1

@Carreau
Copy link
Member Author

Carreau commented Jul 4, 2012

fixed,
As a side note, I skipped IPython/deathrow and IPython/quarantine on purpose.

@takluyver
Copy link
Member

Thanks. Skipping deathrow and quarantine should be fine, as they don't get installed. If anyone updates those, we'll need to check they use the new style - but test_pr should pick that up.

The only other thing to consider is that we're changing external modules, especially pexpect, so we can send the changes upstream (although they might be rejected by projects which still want to support Python < 2.6).

@Carreau
Copy link
Member Author

Carreau commented Jul 4, 2012

Hum, checking again it seems like I did apply 2to3 fo deathrow and quarantine, a * might have slips through... I won't do it for the next changes.

pexpect seem to be dead for 3 years now...

@takluyver
Copy link
Member

I know, I had to fork it: http://pypi.python.org/pypi/pexpect-u

It looks like SSH is just an adapted example, not a real upstream package, so I think we're all OK.

@takluyver
Copy link
Member

Just rerunning the tests. @minrk , any objections to merging this one? It doesn't introduce any ugliness, and I think the new syntax is clearer.

@takluyver
Copy link
Member

Test results for commit 3f213ee merged into master
Platform: linux2

  • python2.7: OK (libraries not available: oct2py rpy2)
  • python3.1: OK (libraries not available: cython matplotlib numpy oct2py pymongo qt rpy2 wx wx.aui zmq)
  • python3.2: OK (libraries not available: cython oct2py pymongo rpy2 wx wx.aui)

Not available for testing: python2.6

@minrk
Copy link
Member

minrk commented Jul 4, 2012

No objection from me.

takluyver added a commit that referenced this pull request Jul 4, 2012
Use new style "except Exception as e" syntax.
@takluyver takluyver merged commit dceb676 into ipython:master Jul 4, 2012
@takluyver
Copy link
Member

Great, I've merged this.

@fperez
Copy link
Member

fperez commented Jul 4, 2012

On Wed, Jul 4, 2012 at 1:51 PM, Thomas Kluyver
reply@reply.github.com
wrote:

Great, I've merged this.


Reply to this email directly or view it on GitHub:
#2064 (comment)

+1

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Use new style "except Exception as e" syntax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants