Skip to content

Prepare for python 3.13 #137

@deathaxe

Description

@deathaxe

I've found references to __file__ in your package:

package_path = os.path.dirname(os.path.abspath(__file__))

As modern python 3.1x releases move on towards __spec__ and drop support for __file__ and __package__ globals, it is recommended to replace relevant references to ensure compatibility with upcoming ST dev builds.

If this package targets ST4 and python 3.8+ it is an easy change by just replacing:

  • __file__ => __spec__.origin
  • __package__ => __spec__.parent

Python 3.3 doesn't support __spec__ and would require a fallback.

A common pattern might be

try:
    package_path = os.path.dirname(__spec__.origin)
except (AttributeError, NameError):
    package_path = os.path.dirname(__file__)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions