Skip to content

Fix import error on Python 3.10: remove trailing commas in StructuredDataType - #3

Open
abrignoni wants to merge 1 commit into
cclgroupltd:mainfrom
abrignoni:fix-py310-enum-trailing-commas
Open

Fix import error on Python 3.10: remove trailing commas in StructuredDataType#3
abrignoni wants to merge 1 commit into
cclgroupltd:mainfrom
abrignoni:fix-py310-enum-trailing-commas

Conversation

@abrignoni

Copy link
Copy Markdown

Six members of StructuredDataType in ccl_mozilla_reader/serialization_formats/ccl_moz_structured_clone_reader.py had a trailing comma after enum.auto(), which turns the value into a tuple. Python 3.11 and newer resolve auto() inside the tuple so it still works there, but Python 3.10 fails as soon as the module is imported:

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'auto'

This PR just removes the six trailing commas (ARRAY_BUFFER_OBJECT_V2, DO_NOT_USE_1, DO_NOT_USE_2, TYPED_ARRAY_OBJECT_V2, DO_NOT_USE_3, DATA_VIEW_OBJECT_V2). I checked that:

  • all 98 enum values are exactly the same before and after on Python 3.12
  • the class now loads fine on Python 3.10

I ran into this through mister_skinnylegs, which ALEAPP uses. The import failure on Python 3.10 made me disable the browser artifact plugins there (abrignoni/ALEAPP#976). Since #2 set requires-python to >=3.10, this small fix makes 3.10 actually work.

Thanks for these tools!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant