Fix copying function annotations and keyword-only defaults on Python 3.
Review Request #9707 — Created Feb. 27, 2018 and submitted — Latest diff uploaded
On Python 3,
FunctionType
's constructor never gained the ability to
specify annotations or defaults for keyword-only arguments. Fortunately,
these are pretty easy to copy over.This change introduces a new
_clone_function()
that does the copying
work, simplifying the copying code we had in two places and adding
support for these missing bits of data.
Unit tests pass for all supported Python versions.