audeering / audobject

Generic Python interface for serializing objects to YAML
https://audeering.github.io/audobject/
Other
1 stars 0 forks source link

Attach source code to dynamically defined functions #23

Closed frankenjoe closed 3 years ago

frankenjoe commented 3 years ago

Closes #22

To solve #22 we attach the source code of a dynamically created function to it.

codecov[bot] commented 3 years ago

Codecov Report

Merging #23 (df8541f) into master (dc747b5) will not change coverage. The diff coverage is 100.0%.

Impacted Files Coverage Δ
audobject/core/resolver.py 100.0% <100.0%> (ø)
hagenw commented 3 years ago

Do you know where user defined functions have the source code stored? So basically where is inspect looking for it?

I'm asking, because at the moment we need to first check for __source__ and if that does not exist call inspect. If we could store the source code at the correct position it wouldn't be necessary. Or does inspect really path files to find the source code?

frankenjoe commented 3 years ago

Do you know where user defined functions have the source code stored?

They don't store it, so we only have the byte code, that's why we need to attach the source code to it.

Or does inspect really path files to find the source code?

Yes, as far as I understood it, inspect really looks at the source file. But since we don't have a source file for dynamically generated functions it fails.

hagenw commented 3 years ago

OK, thanks, then I guess we have to go indeed with the proposed hack here ;)