Skip to content

Commit

Permalink
Improved error handling issue 209 (#263)
Browse files Browse the repository at this point in the history
* catch not enough values to unpack ValueError

* version 6.5.7
  • Loading branch information
jannikmi authored Dec 2, 2024
1 parent 5b5fd27 commit fee9ec2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
Changelog
=========

6.5.7 (2024-12-02)
------------------

* improved error handling to catch ``ValueError: not enough values to unpack`` (`Issue #209 <https://github.com/jannikmi/timezonefinder/issues/209>`__)


6.5.6 (2024-11-25)
6.5.6 (2024-12-02)
------------------

* add musllinux Wheels for Linux. Thanks to `Pxli9130 <https://github.com/Pxli9130 >`__
* add musllinux Wheels for Linux. Thanks to `Pxli9130 <https://github.com/Pxli9130>`__


6.5.5 (2024-11-20)
------------------

* using ``setuptools`` only as a build dependency. Thanks to `Kristian Sloth Lauszus <https://github.com/Lauszus >`__
* using ``setuptools`` only as a build dependency. Thanks to `Kristian Sloth Lauszus <https://github.com/Lauszus>`__


6.5.4 (2024-10-22)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "timezonefinder"
version = "6.5.6"
version = "6.5.7"
description = "python package for finding the timezone of any point on earth (coordinates) offline"
authors = ["jannikmi <github@michelfe.it>"]
license = "MIT"
Expand Down
10 changes: 8 additions & 2 deletions timezonefinder/timezonefinder.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import logging
from abc import ABC, abstractmethod
from io import BytesIO
from pathlib import Path
from struct import unpack
from typing import List, Optional, Tuple, Union

import numpy as np
from h3.api import numpy_int as h3

Expand Down Expand Up @@ -488,11 +488,17 @@ def get_polygon_boundaries(self, poly_id: int) -> Tuple[int, int, int, int]:
"""returns the boundaries of the polygon = (lng_max, lng_min, lat_max, lat_min) converted to int32"""
poly_max_values = getattr(self, POLY_MAX_VALUES)
poly_max_values.seek(4 * NR_BYTES_I * poly_id)
xmax, xmin, ymax, ymin = self._fromfile(
file_result = self._fromfile(
poly_max_values,
dtype=DTYPE_FORMAT_SIGNED_I_NUMPY,
count=4,
)
try:
xmax, xmin, ymax, ymin = file_result
except ValueError as e:
msg = f"error reading boundaries of polygon #{poly_id}, got {file_result}"
logging.error(msg)
raise ValueError(msg) from e
return xmax, xmin, ymax, ymin

def outside_the_boundaries_of(self, poly_id: int, x: int, y: int) -> bool:
Expand Down

0 comments on commit fee9ec2

Please sign in to comment.