Pony ORM is partially broken in Python 3.5 #147

andreymal opened this Issue Oct 4, 2015 · 5 comments


None yet

3 participants


I use Arch Linux with latest updates and Pony 0.6.1 from pip. Example code:

from pony.orm import *

db = Database('sqlite', ':memory:')

class Foo(db.Entity):
    name = Required(str)
    bar = Optional('Bar')

class Bar(db.Entity):
    foos = Set(Foo)


# fail: Foo.select().order_by('1')
# fail: Bar().foos.select()[:]

Traceback (full here):

>>> Bar().foos.select()[:]
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/pony/orm/core.py", line 4672, in filter
    return query._process_lambda(func, globals, locals, order_by=False)
  File "/usr/lib/python3.5/site-packages/pony/orm/core.py", line 4601, in _process_lambda
    func_ast = string2ast(func)
  File "/usr/lib/python3.5/site-packages/pony/orm/core.py", line 4192, in string2ast
    module_node = parse('(%s)' % s)
  File "/usr/lib/python3.5/site-packages/pony/thirdparty/compiler/transformer.py", line 60, in parse
    return Transformer().parsesuite(buf)
  File "/usr/lib/python3.5/site-packages/pony/thirdparty/compiler/transformer.py", line 824, in com_node
    return self._dispatch[node[0]](node[1:])
  File "/usr/lib/python3.5/site-packages/pony/thirdparty/compiler/transformer.py", line 734, in factor
    node = self.lookup_node(nodelist[-1])(nodelist[-1][1:])
  File "/usr/lib/python3.5/site-packages/pony/thirdparty/compiler/transformer.py", line 746, in power
    node = self.com_node(nodelist[0])
  File "/usr/lib/python3.5/site-packages/pony/thirdparty/compiler/transformer.py", line 824, in com_node
    return self._dispatch[node[0]](node[1:])
KeyError: 322

Python 2.7 and 3.4 works fine

@kozlovsky kozlovsky added the bug label Oct 5, 2015
@kozlovsky kozlovsky added this to the 0.6.2 milestone Oct 5, 2015
@kozlovsky kozlovsky self-assigned this Oct 5, 2015
@kozlovsky kozlovsky closed this in 52cb202 Oct 5, 2015

Thanks for reporting! Should work now.


It works, thanks. Don't forget update setup.py :)


Thanks, updated in 776d5e0


How about 0.6.2 release? It's uncomfortable to install from github instead of pypi (and #118 is very bothered on my little production)


At the moment we are working on 0.6.2 and going to release it on Monday, January 11.
Thank you for asking :)

@kozlovsky kozlovsky added a commit that referenced this issue Jan 11, 2016
@kozlovsky kozlovsky Pony ORM Release 0.6.2 (2015-01-11)
The documentation was moved from this repo to a separate one at https://github.com/ponyorm/pony-doc
The compiled version can be found at https://docs.ponyorm.com

# New features

* Python 3.5 support
* #132, #145: raw_sql() function was added
* #126: Ability to use @db_session with generator functions
* #116: Add support to select by UUID
* Ability to get string SQL statement using the Query.get_sql() method
* New function delete(gen) and Query.delete(bulk=False)
* Now it is possible to override Entity.__init__() and declare custom entity methods

# Backward incompatible changes

* Normalizing table names for symmetric relationships
* Autostrip - automatically remove leading and trailing characters

# Bugfixes

* #87: Pony fails with pymysql installed as MySQLdb
* #118: Pony should reconnect if previous connection was created before process was forked
* #121: Unable to update value of unique attribute
* #122: AssertionError when changing part of a composite key
* #127: a workaround for incorrect pysqlite locking behavior
* #136: Cascade delete does not work correctly for one-to-one relationships
* #141, #143: remove restriction on adding new methods to entities
* #142: Entity.select_random() AssertionError
* #147: Add 'atom_expr' symbol handling for Python 3.5 grammar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment