Small changes to print statement function in order to work with py3k. #704

Merged
merged 3 commits into from Sep 9, 2012

Projects

None yet

4 participants

@pr0gg3d
Contributor
pr0gg3d commented Aug 14, 2012

Installing fabric with python3 (via pip) fails because some old print statements.

I have changed the code in order to port all print as functions and using future import for backwards compatibility.

Hope this helps to port fabric to py3k.

Thanks.

@travisbot

This pull request fails (merged e525429 into e005cb6).

@travisbot

This pull request fails (merged 18e5996 into e005cb6).

@travisbot

This pull request passes (merged 082473b into e005cb6).

@pr0gg3d pr0gg3d closed this Aug 14, 2012
@bitprophet
Member

@pr0gg3d did you mean to close this? Please don't let @travisbot scare you off, he's pretty awesome.

Thanks for submitting it, we haven't been perfectly rigorous re: the forward compat.

Do you know offhand if py3k print() is capable of talking stderr? I'd prefer something like print(xxx, sys.stderr) instead of having to do sys.stderr.write() and add extra \n's and such. Not a big deal, just a stylistic thing.

Final note: while Fabric itself can probably run on py3k without a huge amount of pain, and the C-ext we depend on (pyCrypto) is py3k compat in recent versions, I don't think Paramiko/ssh run on 3k well yet. So getting Fab on py3k may not be possible until we have time to make that happen / check out peoples' forks.

@bitprophet bitprophet reopened this Aug 15, 2012
@travisbot

This pull request passes (merged 082473b into e005cb6).

@underrun

print takes a key work only argument file so you can print(something, file=sys.stderr). it seems like there is a paramiko fork that has py3k support ... that be some awesome stuff.

@bitprophet
Member

@underrun Thanks, that's great to know (re: print).

Re: Paramiko forks, yea, there's a few out there (both of paramiko and of ssh which is itself a fork of Paramiko) but AFAIK none of them are 100% there yet. I'll be looking deeper into them at some point.

@bitprophet bitprophet added a commit that referenced this pull request Sep 9, 2012
@bitprophet bitprophet Attribution re #704 2443c52
@bitprophet bitprophet merged commit 082473b into fabric:master Sep 9, 2012

1 check passed

default The Travis build passed
Details
@bitprophet bitprophet added a commit that referenced this pull request Sep 9, 2012
@bitprophet bitprophet Fix up actually-failing tests re #704 6903c62
@bitprophet
Member

Final note-to-self, print(msg, stream) doesn't appear to be valid for Python 2.5, and needs a __future__ import in 2.6 (which I think I saw the OP reverting somewhere in the commit list). So for now we do need to leave it as sys.stderr.write(xxx + "\n").

Fab 2 will be 2.6+ and will be able to use from __future__ import print_function or whatever it is.

@bitprophet bitprophet added the Python 3 label Aug 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment