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

Port sysmodule.c to MS Windows CE #49165

Closed
eckhardt mannequin opened this issue Jan 11, 2009 · 9 comments
Closed

Port sysmodule.c to MS Windows CE #49165

eckhardt mannequin opened this issue Jan 11, 2009 · 9 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@eckhardt
Copy link
Mannequin

eckhardt mannequin commented Jan 11, 2009

BPO 4915
Nosy @loewis
Files
  • python-2.7-wince-sysmodule.0.patch
  • python-2.7-wince-sysmodule.1.patch: patch
  • python-2.7-wince-sysmodule.2.patch: patch
  • 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 2009-01-12.08:04:12.914>
    created_at = <Date 2009-01-11.16:10:05.232>
    labels = ['interpreter-core', 'type-feature']
    title = 'Port sysmodule.c to MS Windows CE'
    updated_at = <Date 2009-01-12.08:04:12.912>
    user = 'https://bugs.python.org/eckhardt'

    bugs.python.org fields:

    activity = <Date 2009-01-12.08:04:12.912>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-01-12.08:04:12.914>
    closer = 'loewis'
    components = ['Interpreter Core']
    creation = <Date 2009-01-11.16:10:05.232>
    creator = 'eckhardt'
    dependencies = []
    files = ['12685', '12689', '12690']
    hgrepos = []
    issue_num = 4915
    keywords = ['patch']
    message_count = 9.0
    messages = ['79600', '79608', '79621', '79622', '79625', '79628', '79629', '79631', '79651']
    nosy_count = 2.0
    nosy_names = ['loewis', 'eckhardt']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue4915'
    versions = ['Python 2.7']

    @eckhardt
    Copy link
    Mannequin Author

    eckhardt mannequin commented Jan 11, 2009

    The attached patch is for sysmodule.c, it contains two changes:

    1. The check whether stdin is a directory is rewritten without using
      fstat(), which doesn't exist under CE.

    2. Replacing sys.argv[0] with the full path is skipped, CE doesn't have
      a current working dir or paths relative to it, so it must already be an
      absolute path.

    @eckhardt eckhardt mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Jan 11, 2009
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 11, 2009

    The S_ISDIR test is to prevent the case

    python < /etc

    Is it really possible to invoke Python in such a way on CE? If not, it
    would be better if the entire test wasn't performed on CE. If it does
    get performed, I think it would be better if the code kept a matching
    number of parentheses (i.e. don't incorporate the opening curly bracket
    into the conditional).

    @eckhardt
    Copy link
    Mannequin Author

    eckhardt mannequin commented Jan 11, 2009

    I don't really know what happens when you try to read()/fread() from
    stdin that is a directory, but I guess it will fail quickly even
    without an explicit check by Python. A directory can be opened under
    win32 just like a file, so I guess that you could also set one as
    stdin for a process. All in all, I don't care whether the check is
    made or not, but it doesn't hurt to be there either.

    I'll submit a changed patch that has the opening curly brackets
    outside the conditional code. Thanks for the review, Martin, I
    appreciate your support on this.

    @eckhardt
    Copy link
    Mannequin Author

    eckhardt mannequin commented Jan 11, 2009

    Changed patch with curly brackets outside the conditional code.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 11, 2009

    I don't really know what happens when you try to read()/fread() from
    stdin that is a directory, but I guess it will fail quickly even
    without an explicit check by Python.

    Without the explicit check, the interpreter crashed; this was the
    reason to add the check in the first place. See bpo-887946.

    A directory can be opened under
    win32 just like a file, so I guess that you could also set one as
    stdin for a process.

    I just tried to run

    python.exe < c:\python25

    on W2k3, and get "Access denied" (instead of getting the error
    message of the Python interpreter). Indeed, it is apparently
    *not* possible to open a directory just like a file under win32.
    As

    http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx

    explains: you must pass FILE_FLAG_BACKUP_SEMANTICS, which
    you normally don't pass.

    Not sure whether this all applies to CE, though.

    All in all, I don't care whether the check is
    made or not, but it doesn't hurt to be there either.

    It does hurt. It clutters the code. So if it could be determined
    that you can't open a directory at all with CreateFile on
    Windows CE, then it would be better if the block was removed,
    than fixed.

    @eckhardt
    Copy link
    Mannequin Author

    eckhardt mannequin commented Jan 11, 2009

    The CE documentation mentions directories, too, but is silent on the
    FILE_FLAG_BACKUP_SEMANTICS use for them. Also, even using that flag, I
    can't open a directory under CE. It seems that this check is
    superfluous there.

    I can also confirm that you get an error if you try to redirect stdin
    via the commandline to a dir even before the executable is even
    launched. The only way to still have a dir as stdin could be to use
    CreateProcess(), but I'm neither sure nor do I care about such abuses.

    Do you want to remove the whole check for MS Windows then? Are you
    otherwise comfortable with the second part of the patch, the one about
    resolving argv[0]?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 11, 2009

    Do you want to remove the whole check for MS Windows then?

    Yes, please. A comment that you can't really redirect from a dir
    on Win32 might be useful.

    Are you
    otherwise comfortable with the second part of the patch, the one about
    resolving argv[0]?

    That's fine - I trust you that the code is not needed on CE.

    @eckhardt
    Copy link
    Mannequin Author

    eckhardt mannequin commented Jan 11, 2009

    Next attempt, exclude all win variants from check.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 12, 2009

    Thanks for the patch. Committed as r68540, r68541.

    @loewis loewis mannequin closed this as completed Jan 12, 2009
    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants