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

BUG: fix StringIO uploads #626

Merged
merged 1 commit into from
Dec 4, 2024
Merged

Conversation

bsipocz
Copy link
Member

@bsipocz bsipocz commented Nov 28, 2024

This is a follow-up to #617 and does fix the issue I see in astroquery.

@bsipocz bsipocz added bug component: dal Affects-dev To be used for follow-up PRs for new engancements or bugs only present on dev labels Nov 28, 2024
@bsipocz bsipocz added this to the v1.6.1 milestone Nov 28, 2024
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.31%. Comparing base (eba8c6f) to head (d5df951).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #626   +/-   ##
=======================================
  Coverage   82.31%   82.31%           
=======================================
  Files          72       72           
  Lines        7429     7429           
=======================================
  Hits         6115     6115           
  Misses       1314     1314           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

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

I get red lights flashing when I see strings and bytes in parallel. I have not tried to ascertain that something will be doing the encoding (to utf-8?), and I note that that is not necessarily trivial for XML (which as encoding indicators inside: a charset attribute in the xml declaration, defaulting to utf-8 if not present).

Given that, I'd really love to have some regression test for that. I'd even bite the bullet and have a remote test for it...

Or is there a simple way to see that the byte/str mix here is unproblematic in this particular context?

@bsipocz
Copy link
Member Author

bsipocz commented Nov 28, 2024

My take on this is that in case of streams we just pass along what we got already on the class instance. Whether that was provided by the user or went through some validation is a separate question.

That being said, I'm happy to add the tap upload test from astroquery as this one smoked the issue out: https://github.com/astropy/astroquery/blob/main/astroquery/alma/tests/test_alma_remote.py#L566

@andamian
Copy link
Contributor

andamian commented Dec 3, 2024

That remote test passes for both BytesIO and StringIO so I assume that requests encodes the string automatically. If requests users expect this to work, I see no reason for us to restrict it.

Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

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

Ok, I'm happy with Adrian's explanation, and I trust requests will be doing something robust, so let's go.

@msdemlei msdemlei merged commit ac3f836 into astropy:main Dec 4, 2024
13 checks passed
@bsipocz bsipocz deleted the BUG_allow_stringIO branch December 4, 2024 17:04
@bsipocz
Copy link
Member Author

bsipocz commented Dec 4, 2024

I still meant to add more tests (practically moving or copying the one from astroquery), but it slipped off the radar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Affects-dev To be used for follow-up PRs for new engancements or bugs only present on dev bug component: dal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants