Skip to content

Can't use Lazy.stringValue from Python #807

@rix0rrr

Description

@rix0rrr

🐛 Bug Report

The following seems like it should work:

import jsii
from aws_cdk import core


class TestpythonStack(core.Stack):

    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # The code that defines your stack goes here
        lazy = core.Lazy.string_value(Producert())

        core.CfnOutput(self, 'Output', value=lazy)


@jsii.implements(core.IStringProducer)
class Producert:
    def produce(self, context):
        return 'whee'

But in fact this leads the runtime to trying to serialize a FUNCTION back to jsii:

[jsii-kernel] fromSandbox registerPostProcessor(pp) { postProcessor = pp; } [{"serializationClass":"Any","typeRef":{"type":{"primitive":"any"}}}]

Which fails (obviously).

Metadata

Metadata

Labels

bugThis issue is a bug.language/pythonRelated to Python bindingsp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions