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

uuid - exception on uuid3/uuid5 #47802

Closed
mgiuca mannequin opened this issue Aug 14, 2008 · 4 comments
Closed

uuid - exception on uuid3/uuid5 #47802

mgiuca mannequin opened this issue Aug 14, 2008 · 4 comments
Labels
build The build process and cross-build stdlib Python modules in the Lib dir

Comments

@mgiuca
Copy link
Mannequin

mgiuca mannequin commented Aug 14, 2008

BPO 3552
Nosy @loewis
Files
  • uuid.patch: Patch for uuid.py, resolves issue
  • 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 2008-08-14.15:52:59.851>
    created_at = <Date 2008-08-14.14:50:27.549>
    labels = ['build', 'library']
    title = 'uuid - exception on uuid3/uuid5'
    updated_at = <Date 2008-08-15.06:24:01.388>
    user = 'https://bugs.python.org/mgiuca'

    bugs.python.org fields:

    activity = <Date 2008-08-15.06:24:01.388>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-08-14.15:52:59.851>
    closer = 'loewis'
    components = ['Library (Lib)']
    creation = <Date 2008-08-14.14:50:27.549>
    creator = 'mgiuca'
    dependencies = []
    files = ['11110']
    hgrepos = []
    issue_num = 3552
    keywords = ['patch']
    message_count = 4.0
    messages = ['71129', '71133', '71156', '71162']
    nosy_count = 2.0
    nosy_names = ['loewis', 'mgiuca']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue3552'
    versions = ['Python 3.0']

    @mgiuca
    Copy link
    Mannequin Author

    mgiuca mannequin commented Aug 14, 2008

    The test suite breaks on the Lib/test/test_uuid.py, as of r65661. This
    is because uuid3 and uuid5 now raise exceptions.

    TypeError: new() argument 1 must be bytes or read-only buffer, not bytearray

    The problem is due to the changes in the way "s#" now expects a
    read-only buffer in PyArg_ParseTupleAndKeywords. (Which was changed in
    r65661).

    A rundown of the problem:

    Lib/uuid.py:553 (in uuid.uuid3):
    hash = md5(namespace.bytes + bytes(name, "utf-8")).digest()

    namespace.bytes is a bytearray, so the argument to md5 is a bytearray.

    Modules/md5module.c:517 (in _md5.md5.new):
    if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist,

    Using s# now requires a read-only buffer, so this raises a TypeError.

    The same goes for uuid5 (which calls _sha1.sha1, and has exactly the
    same problem).

    The commit log for r65561 suggests changing some s# into s* (which
    allows readable buffers). I don't understand the ramifications here
    (some problem with threading), and when I made that change, it seg
    faulted, so I'll leave well enough alone. But for someone who knows more
    what they're doing, that may be a more "root-of-the-problem" fix.

    In the meantime, I propose this simple patch to fix uuid: I think
    namespace.bytes should actually return a bytes, not a bytearray, so I'm
    modifying it to return a bytes.

    Related issue:
    http://bugs.python.org/issue3139

    Patch for r65675.
    Commit log:

    Fixed TypeError raised by uuid.uuid3 and uuid.uuid5, by passing a
    bytearray to hash functions. Now namespace.bytes returns a bytes instead
    of a bytearray.

    @mgiuca mgiuca mannequin added stdlib Python modules in the Lib dir build The build process and cross-build labels Aug 14, 2008
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 14, 2008

    I couldn't reproduce the problem (and apparently, many of the buildbots
    can't, either). It depends on whether you have openssl available, i.e.
    whether hashlib can be built. I explicitly disabled use of OpenSSL on my
    system, and have now committed a fix as r65676.

    @loewis loewis mannequin closed this as completed Aug 14, 2008
    @mgiuca
    Copy link
    Mannequin Author

    mgiuca mannequin commented Aug 15, 2008

    So are you saying that if I had libopenssl (or whatever the name is)
    installed and linked with Python, it would bypass the use of _md5 and
    _sha1, and call the hash functions in libopenssl instead? And all the
    buildbots _do_ have it linked?

    That would indicate that the bots _aren't_ testing the code in _md5 and
    _sha1 at all. Perhaps one should be made to?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 15, 2008

    So are you saying that if I had libopenssl (or whatever the name is)
    installed and linked with Python, it would bypass the use of _md5 and
    _sha1, and call the hash functions in libopenssl instead?

    Correct. Those modules aren't even built then. See openssl_ver in setup.py.

    And all the buildbots _do_ have it linked?

    Most of them, yes, to be able to test openssl. You would have to check
    each one individually to really know.

    That would indicate that the bots _aren't_ testing the code in _md5 and
    _sha1 at all. Perhaps one should be made to?

    Perhaps. However, the buildbots can't test all combinations, anyway.
    People will report problems in other combinations quickly. Hopefully,
    they don't panic when they encounter a bug that only shows up on their
    system.

    @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
    build The build process and cross-build stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants