GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.09k stars 259 forks source link

Doctests failed in CI due to dead link (failed download) #272

Closed JamesParrott closed 1 month ago

JamesParrott commented 1 month ago

PyShp Version

2.3.1

Python Version

All supported

Your code

Example: https://github.com/GeospatialPython/pyshp/actions/runs/9971573815

Dead link in doc tests: https://biogeo.ucdavis.edu/data/diva/rrd/NIC_rrd.zip

Full stacktrace

Run python shapefile.py
Running doctests...
**********************************************************************
File "README.md", line 302, in README
Failed example:
    sf = shapefile.Reader("https://biogeo.ucdavis.edu/data/diva/rrd/NIC_rrd.zip")
Exception raised:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.13/urllib/request.py", line 1318, in do_open
        h.request(req.get_method(), req.selector, req.data, headers,
      File "/usr/local/lib/python3.13/http/client.py", line 1327, in request
        self._send_request(method, url, body, headers, encode_chunked)
      File "/usr/local/lib/python3.13/http/client.py", line 1373, in _send_request
        self.endheaders(body, encode_chunked=encode_chunked)
      File "/usr/local/lib/python3.13/http/client.py", line 1322, in endheaders
        self._send_output(message_body, encode_chunked=encode_chunked)
      File "/usr/local/lib/python3.13/http/client.py", line 1081, in _send_output
        self.send(msg)
      File "/usr/local/lib/python3.13/http/client.py", line 1025, in send
        self.connect()
      File "/usr/local/lib/python3.13/http/client.py", line 1461, in connect
        super().connect()
      File "/usr/local/lib/python3.13/http/client.py", line 991, in connect
        self.sock = self._create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.13/socket.py", line 851, in create_connection
        raise exceptions[0]
      File "/usr/local/lib/python3.13/socket.py", line 836, in create_connection
        sock.connect(sa)
    TimeoutError: [Errno 110] Connection timed out

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.13/doctest.py", line 1374, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest README[7]>", line 1, in <module>
        sf = shapefile.Reader("https://biogeo.ucdavis.edu/data/diva/rrd/NIC_rrd.zip")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/__w/pyshp/pyshp/shapefile.py", line 970, in __init__
        resp = urlopen(req)
               ^^^^^^^^^^^^
      File "/usr/local/lib/python3.13/urllib/request.py", line 189, in urlopen
        return opener.open(url, data, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.13/urllib/request.py", line 489, in open
        response = self._open(req, data)
                   ^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.13/urllib/request.py", line 506, in _open
        result = self._call_chain(self.handle_open, protocol, protocol +
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.13/urllib/request.py", line 466, in _call_chain
        result = func(*args)
                 ^^^^^^^^^^^
      File "/usr/local/lib/python3.13/urllib/request.py", line 1366, in https_open
        return self.do_open(http.client.HTTPSConnection, req,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.13/urllib/request.py", line 1321, in do_open
        raise URLError(err)
    urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>
**********************************************************************
1 items had failures:
   1 of 269 in README
***Test Failed*** 1 failures.
Error: Process completed with exit code 1.

Other notes

Possible solutions:
add the zip file to large file storage assocciated with this repo. add the zip file to archive.org change the doc test so that it does not require a URL to be up.

JamesParrott commented 1 month ago

Partially fixed by: https://github.com/GeospatialPython/pyshp/commit/daab62f87fb5578fbd9aaf487d59a135212cad40

JamesParrott commented 1 month ago

Fixed by daab62f