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

Py3k #324

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Py3k #324

wants to merge 5 commits into from

Conversation

spulec
Copy link

@spulec spulec commented Feb 11, 2013

I'm skeptical that everything will actually work with python3, but all the tests are passing.

It's a start...

Anything that breaks with python3 should result in a new test.

@danielward
Copy link

Am I missing something? I've tried to install with pip and easy_install under Python 3.3 and the installation fails. If you need further information please let me know and I'll get it across to you. Maybe I should be installing from the repo rather than PyPI?

@spulec
Copy link
Author

spulec commented Nov 2, 2013

Can you let us know what fails? A traceback or something?

This pull request hasn't been merged in yet so there is no chance that installing from PyPI will work yet.

@danielward
Copy link

Forget what I've put, I've realised after going through the issues that this was a pull request (!), I'll look at installing the changes you've submitted and let you know how I get on ;)

@danielward
Copy link

Right ok, so this is what I've found thus far:

I have to manually install the following packages:

After this, when running lettuce, I'm presented with the following error:

Traceback (most recent call last):
  File "/.../bin/lettuce", line 9, in <module>
    load_entry_point('lettuce==0.2.12', 'console_scripts', 'lettuce')()
  File "/.../lib/python3.3/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/.../lib/python3.3/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/.../lib/python3.3/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/__init__.py", line 35, in <module>
    from lettuce.terrain import after
  File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/terrain.py", line 32, in <module>
    @world.absorb
  File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/terrain.py", line 23, in absorb
    if not isinstance(name, basestring):
NameError: global name 'basestring' is not defined

@apieum
Copy link
Contributor

apieum commented Nov 2, 2013

hi,
also, exceptions syntax has changed in python3.

this:

except Exception, e:

must be replaced by:

except Exception as e:

2013/11/2 Daniel Ward notifications@github.com

Right ok, so this is what I've found thus far:

I have to manually install the following packages:

After this, when running lettuce, I'm presented with the following error:

Traceback (most recent call last):
File "/.../bin/lettuce", line 9, in
load_entry_point('lettuce==0.2.12', 'console_scripts', 'lettuce')()
File "/.../lib/python3.3/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/.../lib/python3.3/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/.../lib/python3.3/site-packages/pkg_resources.py", line 2260, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/init.py", line 35, in
from lettuce.terrain import after
File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/terrain.py", line 32, in
@world.absorb
File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/terrain.py", line 23, in absorb
if not isinstance(name, basestring):
NameError: global name 'basestring' is not defined

Given that Python 3 supports unicode natively, my understanding is that
this would be the only change:

isinstance(name, str)


Reply to this email directly or view it on GitHubhttps://github.com//pull/324#issuecomment-27620984
.

@grigi
Copy link

grigi commented Nov 4, 2013

@danielward
I also ported sure to py3.2: (in case the pypi version doesn't work for you)
https://github.com/grigi/sure (Python 3 support, which has not yet been merged in to the primary repo)

Also the Py3 porting guide has this to say:
The builtin basestring abstract type was removed. Use str instead. The str and bytes types don’t have functionality enough in common to warrant a shared base class. The 2to3 tool (see below) replaces every occurrence of basestring with str.

Actually to not break Py2 support you should do something like this:

try:
  unicode = unicode
except NameError:
  unicode = str
  basestring = (str, bytes)

I was working on getting all of lettuces dependancies working on Py3 first, once they get merged I was going to tackle lettuce Py3 support. Unfortunately it has been a month since I did the pull requests...

@danielward
Copy link

I'm not sure if you've looked at it, though six library looks really nice to use as a way of providing both Python 2 and Python 3 support in your projects.

Regarding the syntax changes with Exception as ... , print(...), del(...) etc, I'm pretty sure these changes were back ported to at least 2.7 maybe earlier.

Unfortunately the lack of activity on lettuce has meant me looking at other libraries, and I'm afraid I'll be defecting to behave as the documentation is an improvement and isn't too much of a leap. Contributions for the likes of Python 3 should be of utmost importance but the requests are either being ignored or the repo has become dormant for one reason or another which is a real shame :(

@e0ne
Copy link

e0ne commented Nov 20, 2013

I tried to port lettuce to Py3k. The biggest problem is that python-mox lib is not suppopred since November, 2012. What about migration to mock? It it in Python Standard Library now

@danni
Copy link
Collaborator

danni commented Jan 21, 2014

I endorse mock. Also if you're not keen on six, have a look at python-future.

@danni
Copy link
Collaborator

danni commented Feb 12, 2014

I've got a branch that extensively refactors the core of Lettuce (#429), I am taking the time as part of this work to try and makes things as Python3/unicode clean as I possibly can. Once this is done I'm going to attempt porting to Python 3 using python-future as the compatibility layer.

@rpaloschi
Copy link

Hey guys
I think I made some steps... decided to put my work here:
https://github.com/rpaloschi/lettuce

@rpaloschi
Copy link

It is working with python 3 and django 1.6.2. Maybe we can put all this efforts together

@fdcds fdcds mentioned this pull request Jun 29, 2020
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

7 participants