Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pct2rgb.py: "AttributeError: 'NoneType' object has no attribute 'GetCount'" error if the color table is missing in the input raster #8793

Closed
agiudiceandrea opened this issue Nov 23, 2023 · 0 comments
Assignees

Comments

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Nov 23, 2023

Expected behavior and actual behavior.

In case pct2rgb.py is executed against a source raster file without a color table, then the following Python error is displayed:

F:\QGIS\OSGEO4~2.3\qgis\apps\Python39\lib\site-packages\osgeo\gdal.py:290: FutureWarning: Neither gdal.UseExceptions() nor gdal.DontUseExceptions() has been explicitly called. In GDAL 4.0, exceptions will be enabled by default. 
warnings.warn(
Traceback (most recent call last):
File "F:\QGIS\OSGEO4~2.3\qgis\apps\Python39\lib\site-packages\osgeo_utils\auxiliary\gdal_argparse.py", line 175, in main 
self.doit(**kwargs)
File "F:\QGIS\OSGEO4~2.3\qgis\apps\Python39\lib\site-packages\osgeo_utils\pct2rgb.py", line 220, in doit 
return pct2rgb(**kwargs)
File "F:\QGIS\OSGEO4~2.3\qgis\apps\Python39\lib\site-packages\osgeo_utils\pct2rgb.py", line 88, in pct2rgb 
ct_size = ct.GetCount() 
AttributeError: 'NoneType' object has no attribute 'GetCount'

I think it would be better to gracefully handle that case and raise an exception.

Operating system

Windows 10 64 bit

GDAL version and provenance

GDAL 3.7.3 from OSGeo4W

@rouault rouault self-assigned this Nov 30, 2023
@rouault rouault closed this as completed in 21a23a0 Dec 1, 2023
rouault added a commit that referenced this issue Dec 1, 2023
pct2rgb.py: emit explicit exception when source file has no color table (fixes #8793)
rouault added a commit that referenced this issue Dec 1, 2023
[Backport release/3.8] pct2rgb.py: emit explicit exception when source file has no color table (fixes #8793)
ralphraul pushed a commit to 1SpatialGroupLtd/gdal that referenced this issue Mar 11, 2024
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

No branches or pull requests

2 participants