[ 
https://issues.apache.org/jira/browse/CASSANDRA-17433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727210#comment-17727210
 ] 

Leonard Ma commented on CASSANDRA-17433:
----------------------------------------

Made the suggested changes in the PR - 
[https://github.com/apache/cassandra/pull/2378] .   

I'm not sure if this is intentional, but the existing logic seems to imply that 
if we have both timezone configured in settings and environment, the 
environment value will always take precedence:
{code:java}
if options.timezone:
    try:
        timezone = pytz.timezone(options.timezone)
    except Exception:
        sys.stderr.write("Warning: could not recognize timezone '%s' specified 
in cqlshrc\n\n" % (options.timezone))
if 'TZ' in os.environ:
    try:
        timezone = pytz.timezone(os.environ['TZ'])
    except Exception:
        sys.stderr.write("Warning: could not recognize timezone '%s' from 
environment value TZ\n\n" % (os.environ['TZ'])){code}
For now, I emulated the approach we currently have for the pytz library.

 

> Revise use of pytz in Python >= 3.9 
> ------------------------------------
>
>                 Key: CASSANDRA-17433
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17433
>             Project: Cassandra
>          Issue Type: Task
>          Components: CQL/Interpreter
>            Reporter: Brad Schoening
>            Assignee: Leonard Ma
>            Priority: Low
>             Fix For: 5.x
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> PEP 615 – Support for the IANA Time Zone Database in the Standard Library 
> class ZoneInfo
> PEP 615 (Python 3.9) has obsoleted the 3rd party Olsen tz library 'pytz' with 
> support for the IANA Time Zone Database.  The code which imports this in 
> cqlshmain.py and tests in 
> [test_cqlsh_output.py|https://github.com/apache/cassandra/pull/1493/files/9c658a20c669d11a54ecc6b42ba083da13de0103#diff-f5a3955faadf50a1292df481044b83cefc44b2dac46676022c80bad076491a50]
>  should be updated accordingly.
> This can be done with something like:
> if sys.version_info >= (3,9):
>     try:
>         import zoneinfo
> else:
>     try:
>         import pytz
>         ...



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to