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

Test suite failure under python3.4 #175

Closed
sqlalchemy-bot opened this Issue Feb 18, 2014 · 5 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Feb 18, 2014

Migrated issue, originally created by xnox (@xnox)

======================================================================
ERROR: tests.test_op.test_naming_changes

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/xnox/personal-src/alembic/tests/test_op.py", line 636, in test_naming_changes
op.alter_column("t", "c", name="x")
TypeError: alter_column() got an unexpected keyword argument 'name'


Looks like util function to provide compat / older kagrs doesn't work any more =(

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Feb 19, 2014

Michael Bayer (@zzzeek) wrote:

I think I want to wait and see what they do with 3.4 as I can see where this happens, but I cannot create an isolated test case which reproduces it.

this patch "fixes":

diff --git a/alembic/util.py b/alembic/util.py
index 015f732..b4a54dc 100644
--- a/alembic/util.py
+++ b/alembic/util.py
@@ -325,7 +325,9 @@ def _with_legacy_names(translations):
                 metadata)
         decorated = eval(code, {"target": go})
         decorated.__defaults__ = getattr(fn, '__func__', fn).__defaults__
-        return update_wrapper(decorated, fn)
+        f2 = update_wrapper(decorated, fn)
+        del f2.__wrapped__
+        return f2
 
     return decorate
 

and the issue in question is http://bugs.python.org/issue17482.

however I can't get a simple reproduction case to fail and I've no idea why (I've tried much simpler forms of this, the one below is trying to duplicate as many elements of the real decorator as possible, no effect):

from functools import update_wrapper

def my_wrapper(fn):
    def targ(*arg, **kw):
        print("targ")
        return fn(*arg, **kw)
    code = "lambda self, x, y, z, **kw: target(x, y, z)"
    wrapper = eval(code, {"target": targ})
    wrapper.__defaults__ = fn.__defaults__
    wp = update_wrapper(wrapper, fn)
    return wp

class MyClass(object):
    @my_wrapper
    def my_function(self, x, y, z=5):
        print(x, y, z)

MyClass().my_function(1, 2, z=5, q=9)
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Feb 19, 2014

Michael Bayer (@zzzeek) wrote:

basically this is the run scenario:

#!

python3.3 -m nose.core -v tests.test_op:test_naming_changes -s
tests.test_op.test_naming_changes ... /Users/classic/dev/alembic/alembic/util.py:319: UserWarning: Argument 'name' is now named 'new_column_name' for function 'alter_column'
  (oldname, newname, fn.__name__))
/Users/classic/dev/alembic/alembic/util.py:319: UserWarning: Argument 'tablename' is now named 'table_name' for function 'drop_index'
  (oldname, newname, fn.__name__))
/Users/classic/dev/alembic/alembic/util.py:319: UserWarning: Argument 'type' is now named 'type_' for function 'drop_constraint'
  (oldname, newname, fn.__name__))
Unknown arguments: badarg2, badarg1
ok

python3.4 -m nose.core -v tests.test_op:test_naming_changes -s
tests.test_op.test_naming_changes ... ERROR

======================================================================
ERROR: tests.test_op.test_naming_changes
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/classic/dev/alembic/tests/test_op.py", line 636, in test_naming_changes
    op.alter_column("t", "c", name="x")
TypeError: alter_column() got an unexpected keyword argument 'name'

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Feb 19, 2014

xnox (@xnox) wrote:

Thanks for looking into this. I'll ask barry to look into it. I think he might be interested.

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Feb 19, 2014

Michael Bayer (@zzzeek) wrote:

I figured out where it was going wrong, and it was later when we copy out Operations to the "op" namespace, and that makes sense so the approach I have to del __wrapped__ is the most appropriate for now. 2cb07ff2fcbcda4084cfa1654cbd4

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Feb 19, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment