flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

[python] Missing class in generated code for unions

Open cryptocode opened this issue 5 years ago • 10 comments

Below are three fbs files, two of which includes assets.fbs which contains a union. Depending on compilation order, the generated Python code is missing a class.

assets.fbs

union Asset {}

game.fbs

include "assets.fbs";

table GameData {
	asset: Asset;
}
root_type GameData;

player.fbs

include "assets.fbs";

Depending on the compilation order, you'll get either:

Asset.py (INCORRECT, player.fbs is compiled last)

def AssetCreator(unionType, table):
    from flatbuffers.table import Table
    if not isinstance(table, Table):
        return None
    return None

or

Asset.py (CORRECT, player.fbs is compiled first)

class Asset(object):
    NONE = 0


def AssetCreator(unionType, table):
    from flatbuffers.table import Table
    if not isinstance(table, Table):
        return None
    return None

In other words, if player.fbs is compiled last, an invalidAsset.py without the Asset class is generated.

cryptocode avatar Jan 01 '20 23:01 cryptocode

@rw may know

aardappel avatar Jan 02 '20 00:01 aardappel

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

github-actions[bot] avatar Jul 02 '20 20:07 github-actions[bot]

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

github-actions[bot] avatar Jan 02 '21 20:01 github-actions[bot]

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

github-actions[bot] avatar Jul 05 '21 20:07 github-actions[bot]

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

github-actions[bot] avatar Jan 04 '22 20:01 github-actions[bot]

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Mar 04 '23 01:03 github-actions[bot]

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Sep 03 '23 20:09 github-actions[bot]

Unable to add not-stale, so adding this comment. This bug is still around.

cryptocode avatar Sep 04 '23 07:09 cryptocode

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Mar 04 '24 20:03 github-actions[bot]

Not stale (unable to add label) - bug still around

cryptocode avatar Mar 04 '24 22:03 cryptocode