Skip to content

bpo-26185: Fix repr() on empty ZipInfo object#13441

Merged
DinoV merged 3 commits into
python:masterfrom
BoboTiG:fix-issue-26185
Sep 9, 2019
Merged

bpo-26185: Fix repr() on empty ZipInfo object#13441
DinoV merged 3 commits into
python:masterfrom
BoboTiG:fix-issue-26185

Conversation

@BoboTiG

@BoboTiG BoboTiG commented May 20, 2019

Copy link
Copy Markdown
Contributor

It was failing on AttributeError due to inexistant but required attributes file_size and compress_size.
They are now initialized to 0 in ZipInfo.__init__().

Note that this is a second patch: Matthew Zipay wrote a first one back in 2016 (see it on BPO).
I wanted propose something else less "magic". I do not mind closing this one if it is not the good patch to apply :)

https://bugs.python.org/issue26185

It was failing on AttributeError due to inexistant
but required attributes file_size and compress_size.
They are now initialized to 0 in ZipInfo.__init__().
@takluyver

Copy link
Copy Markdown
Contributor

This isn't up to me, but I prefer the more explicit, less magical approach you've used here than the __getattr__ trick in the original patch.

There's a hasattr(zinfo, 'file_size') elsewhere in the file which should be unnecessary with this change.

@BoboTiG

BoboTiG commented May 20, 2019

Copy link
Copy Markdown
Contributor Author

You are right, thank you :)

@BoboTiG

BoboTiG commented Jul 13, 2019

Copy link
Copy Markdown
Contributor Author

[EuroPython 2019] cc @zooba.

@DinoV
DinoV merged commit 992347d into python:master Sep 9, 2019
@bedevere-bot

Copy link
Copy Markdown

@DinoV: Please replace # with GH- in the commit message next time. Thanks!

@BoboTiG
BoboTiG deleted the fix-issue-26185 branch September 9, 2019 13:33
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
* bpo-26185: Fix repr() on empty ZipInfo object

It was failing on AttributeError due to inexistant
but required attributes file_size and compress_size.
They are now initialized to 0 in ZipInfo.__init__().

* Remove useless hasattr() in ZipInfo._open_to_write()

* Completely remove file_size setting in _open_to_write().
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.

6 participants