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

Warning: "'swprintf' : format string '%s' requires an argument of type 'unsigned short *', but variadic argument 1 has type 'const char *'" #89829

Closed
sobolevn opened this issue Oct 29, 2021 · 5 comments
Labels
3.11 only security fixes build The build process and cross-build type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

BPO 45666
Nosy @serhiy-storchaka, @sobolevn, @Fidget-Spinner
PRs
  • bpo-45666: fixes warning with swprintf and %s #29307
  • bpo-45666: Use %S for MSVC and %s elsewhere for swprintf in _testembed.c #29341
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-01.12:14:53.830>
    created_at = <Date 2021-10-29.09:46:48.235>
    labels = ['type-bug', 'build', '3.11']
    title = 'Warning: "\'swprintf\' : format string \'%s\' requires an argument of type \'unsigned short *\', but variadic argument 1 has type \'const char *\'"'
    updated_at = <Date 2021-11-01.12:14:53.829>
    user = 'https://github.com/sobolevn'

    bugs.python.org fields:

    activity = <Date 2021-11-01.12:14:53.829>
    actor = 'kj'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-01.12:14:53.830>
    closer = 'kj'
    components = ['Build']
    creation = <Date 2021-10-29.09:46:48.235>
    creator = 'sobolevn'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45666
    keywords = ['patch']
    message_count = 5.0
    messages = ['405296', '405391', '405393', '405436', '405437']
    nosy_count = 3.0
    nosy_names = ['serhiy.storchaka', 'sobolevn', 'kj']
    pr_nums = ['29307', '29341']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45666'
    versions = ['Python 3.11']

    @sobolevn
    Copy link
    Member Author

    Right now GitHub emmits this warning:

    GitHub Actions / Windows (x64)
    
    Programs/_testembed.c#L1735
    
    'swprintf' : format string '%s' requires an argument of type 'unsigned short *', but variadic argument 1 has type 'const char *' [D:\a\cpython\cpython\PCbuild\_testembed.vcxproj]
    
    

    Example: https://github.com/python/cpython/pull/29272/files#file-programs-_testembed-c-L1735

    Source:

    else if (swprintf(optval, 100, L"frozen_modules=%s", rawval) < 0) {

    I will send a PR with the fix.

    @sobolevn sobolevn added stdlib Python modules in the Lib dir 3.11 only security fixes type-bug An unexpected behavior, bug, or error build The build process and cross-build and removed stdlib Python modules in the Lib dir labels Oct 29, 2021
    @Fidget-Spinner
    Copy link
    Member

    New changeset aad4806 by Nikita Sobolev in branch 'main':
    bpo-45666: fixes warning with swprintf and %s (GH-29307)
    aad4806

    @serhiy-storchaka
    Copy link
    Member

    From the man page:

       S      (Not in C99 or C11, but in SUSv2, SUSv3, and SUSv4.)  Synonym for ls.  Don't use.
    

    @Fidget-Spinner
    Copy link
    Member

    New changeset 401d25e by Nikita Sobolev in branch 'main':
    bpo-45666: Use %S for MSVC and %s elsewhere for swprintf in _testembed.c (GH-29341)
    401d25e

    @Fidget-Spinner
    Copy link
    Member

    @serhiy Thanks for catching my mistake. I'm glad you came across the PR.

    And thank you @nikita for your patience. Closing this issue!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes build The build process and cross-build type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants