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

os.path.abspath(os.devnull) returns \\\\nul should be nul? #52157

Closed
abakker mannequin opened this issue Feb 11, 2010 · 7 comments
Closed

os.path.abspath(os.devnull) returns \\\\nul should be nul? #52157

abakker mannequin opened this issue Feb 11, 2010 · 7 comments
Labels
easy OS-windows type-bug An unexpected behavior, bug, or error

Comments

@abakker
Copy link
Mannequin

abakker mannequin commented Feb 11, 2010

BPO 7909
Nosy @birkenfeld, @amauryfa, @jaraco, @orsenthil, @ezio-melotti
Files
  • issue7909-test.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 2010-07-31.21:40:52.387>
    created_at = <Date 2010-02-11.15:09:43.618>
    labels = ['easy', 'type-bug', 'OS-windows']
    title = 'os.path.abspath(os.devnull) returns \\\\\\\\nul should be nul?'
    updated_at = <Date 2010-07-31.21:40:52.385>
    user = 'https://bugs.python.org/abakker'

    bugs.python.org fields:

    activity = <Date 2010-07-31.21:40:52.385>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-07-31.21:40:52.387>
    closer = 'georg.brandl'
    components = ['Windows']
    creation = <Date 2010-02-11.15:09:43.618>
    creator = 'abakker'
    dependencies = []
    files = ['16419']
    hgrepos = []
    issue_num = 7909
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['99212', '99275', '99276', '99278', '100319', '100329', '112211']
    nosy_count = 7.0
    nosy_names = ['georg.brandl', 'amaury.forgeotdarc', 'jaraco', 'orsenthil', 'abakker', 'ezio.melotti', 'l0nwlf']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'test needed'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7909'
    versions = ['Python 2.6', 'Python 2.7']

    @abakker
    Copy link
    Mannequin Author

    abakker mannequin commented Feb 11, 2010

    I encountered this when somebody used:

    logging.basicConfig(level=logging.CRITICAL,
    format='%(asctime)s %(levelname)-8s %(message)s',
    datefmt='%a, %d %b %Y %H:%M:%S',
    filename=os.devnull,
    filemode='w')

    the logging code apparently calls os.path.abspath(filename) somewhere,
    causing an exception:
    File "c:\python264\lib\logging\init.py", line 838, in _open
    stream = open(self.baseFilename, self.mode)
    IOError: [Errno 2] No such file or directory: '\\\\nul'

    @abakker abakker mannequin added the OS-windows label Feb 11, 2010
    @ezio-melotti ezio-melotti added the type-bug An unexpected behavior, bug, or error label Feb 11, 2010
    @l0nwlf
    Copy link
    Mannequin

    l0nwlf mannequin commented Feb 12, 2010

    Seems fine to me, does not raise any errors. My OS is OS X Snow Leopard. I checked it in python 2.5, 2.6, 2.7 too, no issues raised.

    Shashwat-Anands-MacBook-Pro:test l0nwlf$ python2.6
    Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os,logging
    >>> logging.basicConfig(level=logging.CRITICAL,
    ...                     format='%(asctime)s %(levelname)-8s %(message)s',
    ...                     datefmt='%a, %d %b %Y %H:%M:%S',
    ...                     filename=os.devnull,
    ...                     filemode='w')
    >>>

    @orsenthil
    Copy link
    Member

    From the bug report, it look likes its specific to windows, not OS X.

    @amauryfa
    Copy link
    Member

    nul is a special "dos device"
    _getfullpathname() correctly returns \\.\nul, but normpath() then simplifies it to \\nul

    I suggest that normpath() be changed to consider \\.\ as a special prefix, and keep it intact when it appears at the start of the path. See also
    http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

    @amauryfa amauryfa added the easy label Feb 12, 2010
    @jaraco
    Copy link
    Member

    jaraco commented Mar 3, 2010

    This bug does not exhibit in Python 3.1.1.

    @jaraco
    Copy link
    Member

    jaraco commented Mar 3, 2010

    Attaching a test against trunk which elicits the error reported in this bug.

    @birkenfeld
    Copy link
    Member

    Followed Amaury's suggestion in r83368. \\.\ and \\?\ as prefixes now cause normpath() to return the argument as-is.

    @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
    easy OS-windows type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants