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

Inconsistency with sys.version_info #666

Closed
omus opened this issue Mar 14, 2019 · 4 comments
Closed

Inconsistency with sys.version_info #666

omus opened this issue Mar 14, 2019 · 4 comments

Comments

@omus
Copy link

omus commented Mar 14, 2019

In Python 3.7.2:

Python 3.7.2 (default, Feb 12 2019, 08:16:38)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=7, micro=2, releaselevel='final', serial=0)
>>> sys.version_info.major
3
>>> sys.version_info[0]
3

Using PyCall 1.90.0:

julia> using PyCall

julia> sys = pyimport("sys")
PyObject <module 'sys' (built-in)>

julia> sys.version_info
(3, 7, 2, "final", 0)

julia> sys.version_info.major
ERROR: type Tuple has no field major
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18

julia> sys.version_info[1]
3

Things get stranger when switching to Python 2:

Python 2.7.16 (default, Mar  4 2019, 09:02:22)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0)
>>> sys.version_info.major
2
>>> sys.version_info[0]
2
julia> using PyCall

julia> sys = pyimport("sys")
PyObject <module 'sys' (built-in)>

julia> sys.version_info
PyObject sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0)

julia> sys.version_info.major
2

julia> sys.version_info[1]
┌ Warning: `getindex(o::PyObject, i::Integer)` is deprecated, use `get(o, i - 1)` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
2
@stevengj
Copy link
Member

stevengj commented Mar 14, 2019

On Python 3 it is a named tuple that is getting converted to tuple. Just do sys.”version_info” to suppress the automatic conversion to Tuple.

@omus
Copy link
Author

omus commented Mar 15, 2019

Thanks. That is helpful. Should the automatic conversion be changed to convert Python named tuples into Julia NamedTuples?

@tkf
Copy link
Member

tkf commented Mar 15, 2019

@omus FYI #175

@omus
Copy link
Author

omus commented Mar 15, 2019

Thanks for the link. Since there is a way to get consistent behaviour using sys."version_info" between various versions of Python and NamedTuple conversion already has an issue I will close this issue.

@omus omus closed this as completed Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants