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

parse_known_intermixed_args() tests failing on CRAN's Debian GNU/Linux testing machines #53

Closed
trevorld opened this issue Nov 16, 2024 · 7 comments · Fixed by #54 or #55
Closed
Assignees
Labels

Comments

@trevorld
Copy link
Owner

trevorld commented Nov 16, 2024

CRAN writes:

Dear maintainer,

Please see the problems shown on
https://cran.r-project.org/web/checks/check_results_argparse.html.

Please correct before 2024-12-07 to safely retain your package on CRAN.

Best wishes,
The CRAN Team

  • Looking at the check pages it seems just the parse_known_intermixed_args() tests are failing on CRAN's Debian GNU/Linux testing machines
  • I speculate those machines have a newer version of Python that returns a slightly different output with parse_known_intermixed_args(). Will need to install a newer version of Python and check.
@trevorld trevorld added the bug label Nov 16, 2024
@trevorld trevorld self-assigned this Nov 16, 2024
@trevorld
Copy link
Owner Author

trevorld commented Nov 16, 2024

  • locally compiled python3.12.5, python3.12.6, python3.12.7, and python3.13.0 from official sources and can't reproduce CRAN's issue with any of those.
  • however can reproduce CRAN's issue running in the r-base rocker project docker container after running apt-get update && apt-get install python3 which seems to install python v3.12.7. Unsure why there is a difference between their Python v3.12.7 installed via apt and mine compiled locally (my local OS is an Ubuntu derivative which is a Debian derivative).

@trevorld
Copy link
Owner Author

trevorld commented Nov 16, 2024

library("argparse")
parser <- ArgumentParser()
parser$add_argument('--foo')
parser$add_argument('cmd')
parser$add_argument('rest', nargs='*', type='integer')
args <- strsplit('doit 1 --foo bar 2 3 -n 4', ' ')[[1]]
a_r <- parser$parse_known_intermixed_args(args)

Locally with Python v3.12.7 I see

> a_r
[[1]]
[[1]]$foo
[1] "bar"

[[1]]$cmd
[1] "doit"

[[1]]$rest
[1] 1 2 3


[[2]]
[1] "-n" "4" 

While in r-base with Python v3.12.7 (note the final "4" was put in [[1]]$rest instead of [[2]]):

> a_r
[[1]]
[[1]]$foo
[1] "bar"

[[1]]$cmd
[1] "doit"

[[1]]$rest
[1] 1 2 3 4


[[2]]
[1] "-n"

@trevorld
Copy link
Owner Author

Can see a difference in behaviour with underlying Python 3.12.7:

from argparse import ArgumentParser
import sys

parser = ArgumentParser()
parser.add_argument("--foo")
parser.add_argument("cmd")
parser.add_argument("rest", nargs="*", type=int)
args = ["doit", "1", "--foo", "bar", "2", "3", "-n", "4"]
a_r = parser.parse_known_intermixed_args(args)

print(a_r)
print(sys.version)

When run locally in Python 3.12.7:

(Namespace(foo='bar', cmd='doit', rest=[1, 2, 3]), ['-n', '4'])
3.12.7 (main, Nov 16 2024, 08:02:39) [GCC 11.4.0]

When run in r-base docker in Python 3.12.7 (probably similar to CRAN machine):

(Namespace(foo='bar', cmd='doit', rest=[1, 2, 3, 4]), ['-n'])
3.12.7 (main, Nov  8 2024, 17:55:36) [GCC 14.2.0]

@trevorld
Copy link
Owner Author

Weird, if I download the source for 3.12.7 in r-base and compile from source using ./configure ; make the error seems to go away--it seems to just be a problem with the binary provided by Debian Testing:

(Namespace(foo='bar', cmd='doit', rest=[1, 2, 3]), ['-n', '4'])
3.12.7 (main, Nov 16 2024, 20:18:07) [GCC 14.2.0]

@trevorld
Copy link
Owner Author

I've reported the bug to Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087681

@trevorld trevorld changed the title parse_intermixed_args() tests failing on CRAN's Debian GNU/Linux testing machines parse_known_intermixed_args() tests failing on CRAN's Debian GNU/Linux testing machines Nov 17, 2024
trevorld added a commit that referenced this issue Nov 19, 2024
* Skips two `parse_known_intermixed_args()` tests on CRAN on Debian Testing
  to avoid raising an ERROR due to a bug in Debian Testing's version of python:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087681

closes #53
@trevorld trevorld mentioned this issue Nov 19, 2024
@aitap
Copy link

aitap commented Nov 21, 2024

Apologies for not giving a better explanation on Debian BTS, but this is not only a Debian problem. The new ArgumentParser code in Debian Testing comes from the 3.12 branch of the official cpython repository and will become part of the next 3.12.x and 3.13.x tarballs. The change was a fix for python/cpython#125355. The test will break again on future released versions on Python.

@trevorld trevorld reopened this Nov 21, 2024
@trevorld
Copy link
Owner Author

@aitap Thanks for the follow-up!

trevorld added a commit that referenced this issue Nov 27, 2024
* Tweaks the `parse_known_intermixed_args()` tests so they work with the development version of Python.

closes #53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants