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

Ported to python 3, compatible with python 2 #41

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5d8b31a
fixed many syntax & reference errors; broke compatibility with python…
simonzack Jan 23, 2015
163c41b
hashing doesn't work here, since strings & bytes hash to the same val…
simonzack Jan 22, 2015
c7aa208
fixed next issues
simonzack Jan 23, 2015
7e96377
fixed bool issues
simonzack Jan 23, 2015
275fdad
more portable dict check
simonzack Jan 22, 2015
ff0dd2d
use sorted
simonzack Jan 22, 2015
fa9785f
fixed encoding issues
simonzack Jan 22, 2015
0932f31
use __eq__ instead
simonzack Jan 22, 2015
b15041f
fixed _join
simonzack Jan 23, 2015
06b98bc
type fixes, everything is an object in python
simonzack Jan 23, 2015
11894e6
more type fixes
simonzack Jan 23, 2015
13d7422
use unittest.TestCase instead as the name of the builtins module diff…
simonzack Jan 23, 2015
bbbb38d
store exc_info as it will change on the second sys.exc_info() invocat…
simonzack Jan 23, 2015
9a50898
convert to a local variable
simonzack Jan 23, 2015
2c5fe67
convert to list first
simonzack Jan 23, 2015
f01e6e7
use ModuleType instead
simonzack Jan 23, 2015
5f5dfe9
use `.data` instead
simonzack Jan 23, 2015
771fff1
use the `'b'` array type for testing
simonzack Jan 23, 2015
9aa1210
check whether the class is a classic class, i.e. if we are in python 2
simonzack Jan 23, 2015
045968e
fix python 3 `datetime.utcfromtimestamp` microsecond rounding
simonzack Jan 23, 2015
534bfda
sort object keys so encoding is deterministic, and so tests always pass
simonzack Jan 23, 2015
3e30198
skip classic tests on python 3
simonzack Jan 23, 2015
a4805e5
fixed repr issues
simonzack Jan 23, 2015
3992abb
Merge branch 'master' into python3
simonzack Jan 23, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' into python3
Conflicts:
	distribute_setup.py
	pyamf/adapters/_django_utils_translation.py
	pyamf/alias.py
	pyamf/amf3.py
simonzack committed Jan 23, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3992abbf6987ac5ed05ba5addff2806147671062
42 changes: 35 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -3,14 +3,42 @@ python:
- "2.6"
- "2.7"

install:
- pip install flake8
- pip install -e .
env:
global:
- PYTHONPATH=/tmp/gaesdk

before_script:
matrix:
- USE_EXTENSIONS=true # no dependencies
- USE_EXTENSIONS=false
- USE_EXTENSIONS=true DJANGO_VERSION=1.2.7
- USE_EXTENSIONS=false DJANGO_VERSION=1.2.7
- USE_EXTENSIONS=true DJANGO_VERSION=1.3.7
- USE_EXTENSIONS=false DJANGO_VERSION=1.3.7
- USE_EXTENSIONS=true DJANGO_VERSION=1.5.12
- USE_EXTENSIONS=false DJANGO_VERSION=1.5.12
- USE_EXTENSIONS=true SQLALCHEMY_VERSION=0.7.10
- USE_EXTENSIONS=false SQLALCHEMY_VERSION=0.7.10
- USE_EXTENSIONS=true SQLALCHEMY_VERSION=0.8.7
- USE_EXTENSIONS=false SQLALCHEMY_VERSION=0.8.7
- USE_EXTENSIONS=true SQLALCHEMY_VERSION=0.9.8
- USE_EXTENSIONS=false SQLALCHEMY_VERSION=0.9.8
- USE_EXTENSIONS=true TWISTED_VERSION=14.0.2
- USE_EXTENSIONS=false TWISTED_VERSION=14.0.2
- USE_EXTENSIONS=true GAESDK_VERSION=1.9.17
- USE_EXTENSIONS=false GAESDK_VERSION=1.9.17

before_install:
- pip install flake8
- flake8

install:
- pip install flake8 coverage coveralls
- pip install -e .
- ./install_optional_dependencies.sh
- ./maybe_install_cython.sh

script:
- python setup.py test
- pip install Cython
- python setup.py test
- coverage run --source=pyamf setup.py test

after_success:
- coveralls
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -2,10 +2,9 @@ graft doc
graft pyamf/tests/imports
prune doc/build
prune doc/_build
include distribute_setup.py
include setupinfo.py
include *.txt
global-exclude *.swf
global-exclude *.pyc
include cpyamf/*.pyx
include cpyamf/*.pxd
include cpyamf/*.pxd
3 changes: 3 additions & 0 deletions README.txt → README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.. image:: https://coveralls.io/repos/hydralabs/pyamf/badge.svg
:target: https://coveralls.io/r/hydralabs/pyamf

PyAMF_ provides Action Message Format (AMF_) support for Python_ that is
compatible with the `Adobe Flash Player`_. It includes integration with
Python web frameworks like Django_, Pylons_, Twisted_, SQLAlchemy_,
2 changes: 1 addition & 1 deletion cpyamf/amf3.pxd
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ cdef class ClassDefinition(object):


cdef class Context(codec.Context):
cdef codec.IndexedCollection strings
cdef codec.ByteStringReferenceCollection strings
cdef dict classes
cdef dict class_ref
cdef dict proxied_objects
2 changes: 1 addition & 1 deletion cpyamf/amf3.pyx
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ cdef class Context(codec.Context):
"""

def __cinit__(self):
self.strings = codec.IndexedCollection(use_hash=1)
self.strings = codec.ByteStringReferenceCollection()
self.classes = {}
self.class_ref = {}
self.proxied_objects = {}
11 changes: 11 additions & 0 deletions cpyamf/codec.pxd
Original file line number Diff line number Diff line change
@@ -29,6 +29,17 @@ cdef class IndexedCollection(object):
cpdef Py_ssize_t append(self, object obj) except -1


cdef class ByteStringReferenceCollection(IndexedCollection):
"""
There have been rare hash collisions within a single AMF payload causing
corrupt payloads.

Which strings cause collisions is dependent on the python runtime, each
platform might have a slightly different implementation which means that
testing is extremely difficult.
"""


cdef class Context(object):
"""
C based version of ``pyamf.BaseContext``
21 changes: 20 additions & 1 deletion cpyamf/codec.pyx
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ cdef class IndexedCollection(object):

return <object>self.data[ref]

cdef inline object _ref(self, object obj):
cdef object _ref(self, object obj):
if self.use_hash:
return hash(obj)

@@ -198,6 +198,25 @@ cdef class IndexedCollection(object):
return n


cdef class ByteStringReferenceCollection(IndexedCollection):
"""
There have been rare hash collisions within a single AMF payload causing
corrupt payloads.

Which strings cause collisions is dependent on the python runtime, each
platform might have a slightly different implementation which means that
testing is extremely difficult.
"""

cdef object _ref(self, object obj):
return obj

def __copy__(self):
cdef ByteStringReferenceCollection n = ByteStringReferenceCollection()

return n


cdef class Context(object):
"""
I hold the AMF context for en/decoding streams.
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.