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

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

Merged
merged 3 commits into from Sep 9, 2019

Conversation

BoboTiG
Copy link
Contributor

@BoboTiG BoboTiG commented May 20, 2019

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
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
Copy link
Contributor Author

BoboTiG commented May 20, 2019

You are right, thank you :)

@BoboTiG
Copy link
Contributor Author

BoboTiG commented Jul 13, 2019

[EuroPython 2019] cc @zooba.

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

@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.

None yet

6 participants