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

Python 3 compatibility #39

Closed
22 tasks done
tomgross opened this issue Nov 8, 2015 · 20 comments
Closed
22 tasks done

Python 3 compatibility #39

tomgross opened this issue Nov 8, 2015 · 20 comments

Comments

@tomgross
Copy link
Contributor

tomgross commented Nov 8, 2015

According to caniusepython3 the following packages need some love to get Python 3 support:

Optional dependencies:

Zope itself:

  • Zope
@tseaver
Copy link
Member

tseaver commented Nov 9, 2015

I updated the list with correct capitalizations and links.

@icemac
Copy link
Member

icemac commented Jul 1, 2016

Updated the list with four dependencies that were missing.

@hannosch
Copy link
Contributor

hannosch commented Jul 21, 2016

initgroups turned out to be available in Python's os module in Python 2.7, so I dropped the dependency and made a new initgroups release that is merely a shim for os.initgroups.

For nt_svcutils, I removed the code from zopectl that used this. This was only needed to install and manage a Windows system service. For daemonizing someone can use supervisor or any other tool that provides that.

I also made some progress on ZCTextIndex, by removing its C code and replacing it with pure Python. The speed advantage shouldn't matter that much anymore, and if someone really cares about full text indexing, they'll likely use Solr or Elasticsearch these days.

Finally for DocumentTemplate, I have a branch to replace the C code with pure Python as well, but am not quite finished with that yet (zopefoundation/DocumentTemplate#2).

@hannosch
Copy link
Contributor

I merged the code from Products.OFSP got back into Zope2, as there wasn't much left there. So it'll be done as part of Zope2 itself.

@hannosch
Copy link
Contributor

I've also started to try and break out ZServer and make it an optional dependency. I think it should be possible to create a new ZServer distribution and move the ZServer, Lifetime and webdav packages into it. That new distribution should depend on Zope2, but not the other way around. There's still quite some work to do for that, but it should be possible. With that split, we could make Zope2 Python 3 compatible while using the WSGI publisher, without having to port ZServer at first or ever.

@leorochael
Copy link
Contributor

It should be possible to cut out ZServer from Zope2 without making ZServer depend on Zope2 at all, by moving all the parts that import from ZPublisher into ZPublisher itself, turning ZPublisher into a pure WSGI app and turning ZServer into a pure WSGI HTTP Server.

I expand on this subject here.

@dwt
Copy link
Contributor

dwt commented Oct 4, 2016

I propose linking the respective tracking bugs for python3 compatibility in each project instead of just the projects. Anybody against this?

@icemac
Copy link
Member

icemac commented Oct 21, 2016

@dwt +1

@hannosch
Copy link
Contributor

As a current status, we have a couple of issues / branches / PR's in progress and some of those can be worked on in parallel:

Once all of these are done, work can begin on Zope2 itself. It might be possible to use all the WIP branches to start, but it might not. Once Zope2 is done, work can start on the various Products.* being dependent on Zope2.

@Daetalus
Copy link

Hi @hannosch

Just FYI, I try to let Pyston support Zope. But they didn't support the compiler package, which used by RestrictedPython. After some investigation. I try to use ast to replace compiler in RestrictedPython.

I start it by reading the source code of RestrictedPython. And then compare the ast before and after the MutatingWalker. Then use ast.NodeTransformer to do the same things. It basically a "reverse engineering". But the corner cases took me lots of time. More information is here: https://lab.nexedi.com/Daetalus/RestrictedPython-3.6.0/blob/c4652cb365edfe21e41c20bdf51c92dfab7a283f/src/RestrictedPython/notes.txt

It just a prototype, but in theory, it could work both Python 2/3 and Pyston. I think it's better to let you and other guys to know there already have some efforts to let RestrictedPython to support Python 3. Where to go on next is depend on you. (Just in case, I will resend this message to Zope dev mailist again).

Thanks all!

@hannosch
Copy link
Contributor

@Daetalus Can you put this pointer into the RestrictedPython issue at zopefoundation/RestrictedPython#12. There's a group of people who have been working on a branch there for the past 12 months using the same approach you took.

@hannosch
Copy link
Contributor

Most recent status and some tips for getting an instance / debug it over at #129.

@hannosch
Copy link
Contributor

hannosch commented May 22, 2017

New Zope2 4.0a5 release is up on PyPi.

This still has 2 test errors related to the HTTPRequest.FileUpload class. It's both an old-style class, using old-style class semantics and has to be adjusted to non-trivial changes in cgi.FieldStorage. FileUpload tries to be a half-transparent wrapper around FieldStorage.

There's also three more errors related to ZTUtils.Tree, which needs both correct tests and an implementation. This is de/encoding a tree-state into/from a cookie value.

There are also one or two test failures related to HTTPRequest.processInput parsing.

And finally Products.MailHost isn't yet ported, as the only one of the automatically tested optional dependencies.

@tseaver
Copy link
Member

tseaver commented May 23, 2017

This still has 2 test errors related to the HTTPRequest.FileUpload class. It's both an old-style class, using old-style class semantics and has to be adjusted to non-trivial changes in cgi.FieldStorage. FileUpload tries to be a half-transparent wrapper around FieldStorage.

I think I fixed the FileUpload tests today in #138.

There's also three more errors related to ZTUtils.Tree, which needs both correct tests and an implementation. This is de/encoding a tree-state into/from a cookie value.

I got those tests passing today in #137.

There are also one or two test failures related to HTTPRequest.processInput parsing.

One of those is fixed in #138.

And finally Products.MailHost isn't yet ported, as the only one of the automatically tested optional dependencies.

That one is ugly: the email package APIs want native str on both Python 2 and Python 3, which makes for a bunch of realy ugly branching.

@dataflake
Copy link
Member

I've been working on MailHost, and like Tres says, it's another big string compatibility mess.

@hannosch
Copy link
Contributor

This still has 2 test errors related to the HTTPRequest.FileUpload class. It's both an old-style class, using old-style class semantics and has to be adjusted to non-trivial changes in cgi.FieldStorage. FileUpload tries to be a half-transparent wrapper around FieldStorage.

I think I fixed the FileUpload tests today in #138.

There's still a test failure:

Error in test test_processInputs_with_file_upload_gets_iterator (ZPublisher.tests.testHTTPRequest.HTTPRequestTests)
Traceback (most recent call last):
  File "/opt/python/3.6.1/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/opt/python/3.6.1/lib/python3.6/unittest/case.py", line 601, in run
    testMethod()
  File "/home/travis/build/zopefoundation/Zope/src/ZPublisher/tests/testHTTPRequest.py", line 764, in test_processInputs_with_file_upload_gets_iterator
    self.assertEqual(list(f), ['test\n'])
TypeError: 'FileUpload' object is not iterable

I took that to mean the way FileUpload.__init__ puts methods from the underlying field storage into __dict__ doesn't work anymore. I thought new-style classes either need a __getattribute__ hook to intercept some of these, or in some cases like __iter__ even that isn't enough and it needs the method to be defined explicitly.

@hannosch
Copy link
Contributor

hannosch commented May 31, 2017

Final test failure is fixed and the master branch is green on Py{27,34,35,36}.

Products.MailHost is the last optional but default dependency of Zope which isn't ported yet.

And of course lots of untested code in Zope is likely still wrong ;)

@gotcha
Copy link
Member

gotcha commented Jun 1, 2017

untested code ? really ? :)

@icemac icemac added this to the 4.0b1 milestone Jun 7, 2017
@tseaver
Copy link
Member

tseaver commented Jun 7, 2017

#148 is the biggest unresolved blocker I know of for "core" Zope: I set up an instance yesterday on Python 3.6 and was able to exercise all the default ZMI options except those involving file uploads.

@hannosch
Copy link
Contributor

All the dependencies are done (MailHost is now entirely optional). Closing this in favor of the b1 milestone, which tracks general issues - not only those about Python 3 compatibility.

@hannosch hannosch moved this from Open to Done in Zope 4 beta release Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

9 participants