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

Fix copying Message in pure-python. #15

Merged
merged 2 commits into from Oct 19, 2018
Merged

Fix copying Message in pure-python. #15

merged 2 commits into from Oct 19, 2018

Conversation

jamadden
Copy link
Member

Do it like the C extension does, by actually copying from the other object and then setting attributes if needed.

Also drop old C support code for Python < 2.6

Fixes #14

Do it like the C extension does, by actually copying from the other object and then setting attributes if needed.

Also drop old C support code for Python < 2.6
@jamadden jamadden requested a review from mgedmin October 19, 2018 16:48
self.default = ustr.default[:] if ustr.default else None
self.mapping = ustr.mapping.copy() if ustr.mapping is not None else None
self.msgid_plural = ustr.msgid_plural[:] if ustr.msgid_plural else None
self.default_plural = ustr.default_plural[:] if ustr.default_plural else None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we even trying to slice strings anyway? a_string[:] is a_string in CPython AFAICT. Is the C code doing slices?

(Also I'm mildly unhappy about explicitly making a copy of the mapping dictionary and then throwing it away. I suppose it's a rare occurrence, but still.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered that too. The C code is not slicing strings. Nor does it copy() the mapping. Suppose we just remove that here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests broke if that stops happening. I removed it and added tests to confirm that Python and C are handling the objects the same way.

…trings and (somewhat pointedly) copy mappings, like the C implementation.
Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

(but the change that introduced the bug also looked good to me so caveat emptor)

@jamadden jamadden merged commit 6cb7a6c into master Oct 19, 2018
@jamadden jamadden deleted the issue14 branch October 19, 2018 19:57
@jamadden
Copy link
Member Author

Thanks! Let's roll the dice. Can we get a PyPI release, please? (Or access for jamadden)

@jamadden
Copy link
Member Author

I started the release process and uploaded the git tags before I realised I didn't have PyPI rights. So the 4.3.1 wheels are showing up on PyPI now thanks to the CI services, but not a sdist (.tar.gz).

@tseaver
Copy link
Member

tseaver commented Oct 19, 2018

I just added you as an owner of the PyPI project.

@jamadden
Copy link
Member Author

Thank you! I've uploaded the corresponding .tar.gz

@mgedmin
Copy link
Member

mgedmin commented Oct 20, 2018

For packages where CI uploads wheels perhaps we should also upload sdists (using twine upload --skip-missing), just in case.

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

3 participants