I just tested and was able to reproduce the issue by doing a simple
feature.setAttribute('my_attribute', None)
This has worked in all previous versions of FME and this change has the potential to break a lot of existing code that relies on being able to set a null value using setAttribute().
@safesoftware safesoftware What is the reason for this change in behavior? Do we now have to explicitly test for None values first before attribute assignment, e.g.
if my_value is None:
feature.setAttributeNullWithType('test', FME_ATTR_UNDEFINED)
else:
feature.setAttribute('test', my_value)
Maybe I'm missing something here, but this does not look like an improvement to me.
I just tested and was able to reproduce the issue by doing a simple
feature.setAttribute('my_attribute', None)
This has worked in all previous versions of FME and this change has the potential to break a lot of existing code that relies on being able to set a null value using setAttribute().
@safesoftware safesoftware What is the reason for this change in behavior? Do we now have to explicitly test for None values first before attribute assignment, e.g.
if my_value is None:
feature.setAttributeNullWithType('test', FME_ATTR_UNDEFINED)
else:
feature.setAttribute('test', my_value)
Maybe I'm missing something here, but this does not look like an improvement to me.
Great, thanks for testing. Hopefully it can be fixed really soon!
Edit: the bug also includes the PowerPointWriter for example. I cannot reproduce it with a simple example unfortunately, but as soon as I am able to I'll share it.
I just tested and was able to reproduce the issue by doing a simple
feature.setAttribute('my_attribute', None)
This has worked in all previous versions of FME and this change has the potential to break a lot of existing code that relies on being able to set a null value using setAttribute().
@safesoftware safesoftware What is the reason for this change in behavior? Do we now have to explicitly test for None values first before attribute assignment, e.g.
if my_value is None:
feature.setAttributeNullWithType('test', FME_ATTR_UNDEFINED)
else:
feature.setAttribute('test', my_value)
Maybe I'm missing something here, but this does not look like an improvement to me.
I'm no python expert: @david_r , is there a workaround I can use? (which also works for the standard powerpoint writer?)
I'm no python expert: @david_r , is there a workaround I can use? (which also works for the standard powerpoint writer?)
If it's just for your own Python code, you can use the if-pattern above. If it's the Python code in e.g. the Powerpoint writer that fails, then you've got no other option than going back to whatever version of FME (e.g. 2020.x) from before this surprise introduction of change in behavior, while waiting for Safe to look into it.
I'm no python expert: @david_r , is there a workaround I can use? (which also works for the standard powerpoint writer?)
Unfortunately I discovered the issue after updating FME-server, so there is no way back here for me. But thanks for your help so far
@koenterralytics Thanks @david_r for the reproduction example. We'll try and get this fixed as soon as possible.
Using:
FMEFeature.setAttributeNullWithType(attrName, attrType)
is the recommended approach to setting Null. attrType = 0