-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
len(platform.uname()) has changed in Python 3.9 #84750
Comments
518835f#diff-47c8e5750258a08a6dd9de3e9c3774acL741-R804 That diff changed len(platform.uname()) to 5 (from 6). I noticed because we have some code that checks for 6 strs (arguably unnecessary), Was this effect intentional? |
It was intentional to address bpo-35967, although it was meant to remain compatible. Is len(uname()) an important behavior to retain? It feels like an implementation detail to me. |
If it is important to retain the |
Thanks David for the report and the draft PR (which helped me validate my thinking on the matter). In PR 20015, I've included additional tests. I've also re-written the compatibility functions to rely on the main Another situation that's likely to be incompatible is pickleability. Is that important? I'm tempted to make deprecated the use of |
Hi Jason, to achieve better backwards compatibility, it's probably better to use class CodecInfo(tuple):
"""Codec details when looking up the codec registry"""
def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
incrementalencoder=None, incrementaldecoder=None, name=None,
*, _is_text_encoding=None):
self = tuple.__new__(cls, (encode, decode, streamreader,
streamwriter))
self.name = name
self.encode = encode
self.decode = decode
self.incrementalencoder = incrementalencoder
self.incrementaldecoder = incrementaldecoder
self.streamwriter = streamwriter
self.streamreader = streamreader
if _is_text_encoding is not None:
self._is_text_encoding = _is_text_encoding
return self
def __repr__(self):
return "<%s.%s object for encoding %s at %#x>" % \
(self.__class__.__module__, self.__class__.__qualname__,
self.name, id(self)) This used to be a 4 entry tuple and was extended to hold additional -- Professional Python Services directly from the Experts (#1, May 09 2020)
>>> Python Projects, Coaching and Support ... https://www.egenix.com/
>>> Python Product Development ... https://consulting.egenix.com/
________________________________________________________________________ ::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 |
Thanks Marc-Andre for the suggestion, but I don't think that approach is viable here. The whole point of bpo-35967 was to defer the execution of the Lines 784 to 787 in 77c6146
I created bpo-40578 to track deprecation of uname for positional access. |
I've gone ahead and merged PR 20015 to fix the issue, but I'm happy to revisit if a better approach is proposed. |
Ok, let me add some more context: When I wrote the uname interface Now, you added a late binding optimization for the whole uname return I think this would have been better implemented in the various Line 898 in 77c6146
and below), using a variant of the uname() API, say _uname(), which leaves out the processor information for those APIs which don't need it and only provide the late binding in processor() (which could then also fill in the cache value for uname(). The uname() API would then still do the full lookup, but applications I don't think that deprecating standard tuple access is an option -- Professional Python Services directly from the Experts (#1, May 09 2020)
>>> Python Projects, Coaching and Support ... https://www.egenix.com/
>>> Python Product Development ... https://consulting.egenix.com/
________________________________________________________________________ ::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 |
It wasn't to save the effort and it wasn't an optimization. There was a fundamental race condition where it became impossible to implement a
This idea is interesting, but I believe it also falls prey to the same race condition if any code calls May I suggest that you either revive the conversation in bpo-35967 or open a new ticket to discuss improving the implementation so that the details aren't lost in this ticket, which was specifically about compatibility issues?
I'll address this concern in the ticket I opened about the deprecation. |
Hi Jason, I think I have to review the whole set of changes again to understand what your motivation is/was. For https://bugs.python.org/issue35967 I had already stated that your use case is not special enough to make the platform.py logic more complex. BTW: Please don't open several different tickets for the same problem. It doesn't really help to see what is going on. I'll reopen the bpo-35967 to continue the discussion there. Thanks. |
@malemburg Not sure if this should be a new issue, but
(my emphasis) I've got python 3.10.6 installed, which returns 5 attributes, not including
|
Moved to a new 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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: