have bundled_data_path in a variable initialized in __init__
Successful initialization of the variable with the data path
Init occurred faster than the bundled data folder creation, causing the cog to fail with a "dir could not be found"
Put the following in any cog that has data and try loading the cog:
def __init__(self):
self.path = bundled_data_path(self)
I cannot replicate this, please check the docs regarding this to ensure you remembered to initialize bundled data properly in your setup function prior to cog object creation.
A setup function like this:
def setup(bot):
cog = MyCog(bot)
data_manager.load_bundled_data(cog, __file__)
bot.add_cog(cog)
That would run the __init__ of MyCog before the load_bundled_data has been run.
This is an ordering issue, not really a bug.
As a solution I'd suggest adding a note in the docs of bundled_data_path saying that load_bundled_data must be called before calling bundled_data_path, and perhaps that will clear things up. You still won't be able to call it in __init__, but a workaround is fairly easy:
def setup(bot):
cog = MyCog(bot)
data_manager.load_bundled_data(cog, __file__)
cog.function_which_calls_bundled_data_path()
bot.add_cog(cog)
I disagree with this being solely a docs issue, but also one of usability. It makes sense that a cog would possibly need some of this data at init, and we could accommodate it similarly to config, by adding an optional keyword only parameter for the cog name.
Resolved by #2342. load_bundled_data is now completely obselete and does nothing, simply use bundled_data_path whenever you wish.