Skip to content

Commit

Permalink
Compatibility with PythonScripts
Browse files Browse the repository at this point in the history
Use ``six`` to access the function object and function code in ``zope.publisher.publisher.unwrapMethod``.
This restores compatibility with Products.PythonScripts, where parameters were not extracted.
  • Loading branch information
thet committed May 23, 2016
1 parent 5aae3d9 commit a57d228
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes
4.3.0 (unreleased)
------------------

- Use ``six`` to access the function object and function code in ``zope.publisher.publisher.unwrapMethod``.
This restores compatibility with Products.PythonScripts, where parameters were not extracted.
[maurits, thet]

- Add support for Python 3.5.

- Drop support for Python 2.6 and 3.2.
Expand Down
7 changes: 4 additions & 3 deletions src/zope/publisher/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

_marker = object() # Create a new marker object.


def unwrapMethod(obj):
"""obj -> (unwrapped, wrapperCount)
Expand All @@ -41,14 +42,14 @@ def unwrapMethod(obj):
if bases is not None:
raise TypeError("mapply() can not call class constructors")

im_func = getattr(unwrapped, '__func__', None)
im_func = getattr(unwrapped, six._meth_func, None)
if im_func is not None:
unwrapped = im_func
wrapperCount += 1
elif getattr(unwrapped, '__code__', None) is not None:
elif getattr(unwrapped, six._func_code, None) is not None:
break
else:
unwrapped = getattr(unwrapped, '__call__' , None)
unwrapped = getattr(unwrapped, '__call__', None)
if unwrapped is None:
raise TypeError("mapply() can not call %s" % repr(obj))
else:
Expand Down

1 comment on commit a57d228

@tseaver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using private attributes of the six module, use the public accessors: get_method_function and get_function_code.

Please sign in to comment.