https://github.com/glyph/automat/commit/d0c2845ead9b8f576042d42134bfb5c63086be39

diff --git a/automat/_introspection.py b/automat/_introspection.py
index 3f7307d..403cddb 100644
--- a/automat/_introspection.py
+++ b/automat/_introspection.py
@@ -6,6 +6,8 @@
 
 
 def copycode(template, changes):
+    if hasattr(code, "replace"):
+        return template.replace(**{"co_" + k : v for k, v in changes.items()})
     names = [
         "argcount", "nlocals", "stacksize", "flags", "code", "consts",
         "names", "varnames", "filename", "name", "firstlineno", "lnotab",
@@ -23,7 +25,6 @@ def copycode(template, changes):
     return code(*values)
 
 
-
 def copyfunction(template, funcchanges, codechanges):
     names = [
         "globals", "name", "defaults", "closure",
