-
Notifications
You must be signed in to change notification settings - Fork 8
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
Port to Python 3 #2
Changes from 6 commits
fc59898
512f5ba
edba88c
6c2ece3
e726867
07e92bc
6626c12
0b21786
c7d1ab7
5c39c28
12e3f2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ language: python | |
python: | ||
- 2.7 | ||
- 3.4 | ||
- 3.5 | ||
- 3.6 | ||
install: | ||
- python bootstrap.py | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/bin/sh | ||
openssl genrsa 1024 > sample.key | ||
openssl req -new -x509 -nodes -sha1 -days 3650 -key sample.key > sample.crt | ||
cat sample.crt sample.key > sample.pem | ||
openssl req -new -x509 -nodes -sha256 -days 3650 -key sample.key > sample.crt |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2013 Zope Foundation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE | ||
# | ||
############################################################################## | ||
import sys | ||
from six import PY3 | ||
|
||
# This code was copied from ZODB/_compat.py | ||
|
||
if not PY3: | ||
# Python 2.x | ||
# PyPy's cPickle doesn't have noload, and noload is broken in Python 2.7, | ||
# so we need zodbpickle. | ||
# Get the fastest working version we can (PyPy has no fastpickle) | ||
try: | ||
import zodbpickle.fastpickle as cPickle | ||
except ImportError: | ||
import zodbpickle.pickle as cPickle | ||
Pickler = cPickle.Pickler | ||
Unpickler = cPickle.Unpickler | ||
else: | ||
# Python 3.x: can't use stdlib's pickle because | ||
# http://bugs.python.org/issue6784 | ||
import zodbpickle.pickle | ||
|
||
class Pickler(zodbpickle.pickle.Pickler): | ||
def __init__(self, f, protocol=None): | ||
super(Pickler, self).__init__(f, protocol) | ||
|
||
class Unpickler(zodbpickle.pickle.Unpickler): | ||
def __init__(self, f): | ||
super(Unpickler, self).__init__(f) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why these |
||
|
||
# Py3: Python 3 doesn't allow assignments to find_global, | ||
# instead, find_class can be overridden | ||
|
||
find_global = None | ||
|
||
def find_class(self, modulename, name): | ||
if self.find_global is None: | ||
return super(Unpickler, self).find_class(modulename, name) | ||
return self.find_global(modulename, name) | ||
|
||
|
||
try: | ||
# XXX: why not just import BytesIO from io? | ||
from cStringIO import StringIO as BytesIO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think io.BytesIO is noticeably slower on 2.7. I haven't personally benchmarked, and I don't remember why I think so. It's probably mostly because old code used cStringIO and if we keep using the same thing, we're sure nothing unexpected will break. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know the
(Using cStringIO on Python 2 but BytesIO on Python 3 is confusing and could be a source of bugs, IMO, because they accept different things. cStringIO will happily allow you to mix unicode and bytes, but BytesIO won't.) |
||
except ImportError: | ||
# Python 3.x | ||
from io import BytesIO |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,6 @@ | |
|
||
from hashlib import md5 | ||
|
||
__docformat__ = "reStructuredText" | ||
|
||
logger = logging.getLogger('kmi') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no 3.5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add it.
I didn't put it because I didn't have a python 3.5 environment on my machine, so I didn't test it myself. But travis is here for that!