Skip to content

Commit 9838e88

Browse files
committed
Only create wrappers for methods with a legal Python name
^methods nowadays lists -> (Mu:D \fles: *%_) { #`(Method+{<anon>}|109046056) ... } which obviously cannot be used as a method name in Python. Since a Perl 6 subclass of a Python class may want to use names that would not be legal in Python (e.g. hypenated-names), it's good to filter those anyway.
1 parent b45abdf commit 9838e88

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/Inline/Python.pm6

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ method create_subclass(Str $package, Str $class, Str $subclass_name) {
379379
my $subclass = ::($subclass_name);
380380
my $methods = $subclass\
381381
.^methods\
382+
.grep({$_.gist ~~ /^\w+$/})\
382383
.map({" def {$_.gist}(self, *args): return perl6.invoke(self.__p6_index__, '{$_.gist}', args)"})\
383384
.join("\n");
384385
my $baseclass_name = $package eq '__main__' ?? $class !! "$package.$class";

0 commit comments

Comments
 (0)