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

Input filename for shapefile.Reader() should be a string #2239

Closed
wants to merge 1 commit into from

Conversation

JouleCai
Copy link

Rationale

The input full path name for the function "shapefile.Reader()" should be a string. However, the file name get from e.g. natural_earth() is a pathlib.Path object. This causes an error when reading the data file.

Change
self._reader = reader = shapefile.Reader(filename)
to
self._reader = reader = shapefile.Reader(str(filename))
on line 136 in io/shapereader.py.

The filename as a output of shpreader.natural_earth() is a pathlib.Path object. However, the function "shapefile.Reader()" requires the input filename to be a string.
@JouleCai JouleCai changed the title Input filename for shapereader should be a string Input filename for shapefile.Reader() should be a string Aug 23, 2023
@lgolston
Copy link
Contributor

Maybe this should be applied only for PyShp < 2.3.0? GeospatialPython/pyshp#233 added support for path objects

@QuLogic QuLogic changed the base branch from v0.22.x to main August 24, 2023 07:01
@greglucas
Copy link
Contributor

Maybe this should be applied only for PyShp < 2.3.0? GeospatialPython/pyshp#233 added support for path objects

I think the solution here is for users to upgrade physhp to 2.3.0+? I'm not sure we should be version-gating on this.

@rcomer
Copy link
Member

rcomer commented Nov 28, 2023

Thank you for your work on this @JouleCai, but we decided to increase the required version of pyshp instead. See #2290.

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

Successfully merging this pull request may close these issues.

4 participants