Skip to content

conform to pep 3110#2064

Merged
takluyver merged 4 commits into
ipython:masterfrom
Carreau:pep-3110
Jul 4, 2012
Merged

conform to pep 3110#2064
takluyver merged 4 commits into
ipython:masterfrom
Carreau:pep-3110

Conversation

@Carreau

@Carreau Carreau commented Jun 30, 2012

Copy link
Copy Markdown
Member

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

fperez commented Jun 30, 2012

Copy link
Copy Markdown
Member

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

@Carreau

Carreau commented Jul 1, 2012

Copy link
Copy Markdown
Member Author

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

Carreau commented Jul 1, 2012

Copy link
Copy Markdown
Member Author

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

fperez commented Jul 1, 2012

Copy link
Copy Markdown
Member

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
Copy Markdown
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

Carreau commented Jul 3, 2012

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

Carreau commented Jul 4, 2012

Copy link
Copy Markdown
Member Author

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

Carreau commented Jul 4, 2012

Copy link
Copy Markdown
Member Author

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

Comment thread setup.py Outdated

Copy link
Copy Markdown
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
Copy Markdown
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

Carreau commented Jul 4, 2012

Copy link
Copy Markdown
Member Author

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

@takluyver

Copy link
Copy Markdown
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

Carreau commented Jul 4, 2012

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

minrk commented Jul 4, 2012

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

Great, I've merged this.

@fperez

fperez commented Jul 4, 2012

Copy link
Copy Markdown
Member

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.

4 participants