Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ebd1b1dc
Commit
ebd1b1dc
authored
Jun 22, 2012
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Plain Diff
Merge heads
parents
7c771ca4
1326e8f3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
32 deletions
+43
-32
Doc/library/time.rst
Doc/library/time.rst
+1
-1
Lib/datetime.py
Lib/datetime.py
+3
-3
Lib/test/datetimetester.py
Lib/test/datetimetester.py
+4
-2
Lib/test/test_capi.py
Lib/test/test_capi.py
+21
-19
Modules/_datetimemodule.c
Modules/_datetimemodule.c
+3
-7
Tools/ssl/make_ssl_data.py
Tools/ssl/make_ssl_data.py
+11
-0
No files found.
Doc/library/time.rst
View file @
ebd1b1dc
...
...
@@ -545,7 +545,7 @@ The module defines the following functions and data items:
+-------+-------------------+---------------------------------+
| N/A | :attr:`tm_zone` | abbreviation of timezone name |
+-------+-------------------+---------------------------------+
| N/A | :attr:`tm_gmtoff` | offset
from UTC in seconds
|
| N/A | :attr:`tm_gmtoff` | offset
east of UTC in seconds
|
+-------+-------------------+---------------------------------+
Note that unlike the C structure, the month value is a range of [1, 12], not
...
...
Lib/datetime.py
View file @
ebd1b1dc
...
...
@@ -1510,13 +1510,13 @@ class datetime(date):
# implied by tm_isdst.
delta
=
local
-
datetime
(
*
_time
.
gmtime
(
ts
)[:
6
])
dst
=
_time
.
daylight
and
localtm
.
tm_isdst
>
0
gmtoff
=
_time
.
altzone
if
dst
else
_time
.
timezone
if
delta
==
timedelta
(
seconds
=
-
gmtoff
):
gmtoff
=
-
(
_time
.
altzone
if
dst
else
_time
.
timezone
)
if
delta
==
timedelta
(
seconds
=
gmtoff
):
tz
=
timezone
(
delta
,
_time
.
tzname
[
dst
])
else
:
tz
=
timezone
(
delta
)
else
:
tz
=
timezone
(
timedelta
(
seconds
=
-
gmtoff
),
zone
)
tz
=
timezone
(
timedelta
(
seconds
=
gmtoff
),
zone
)
elif
not
isinstance
(
tz
,
tzinfo
):
raise
TypeError
(
"tz argument must be an instance of tzinfo"
)
...
...
Lib/test/datetimetester.py
View file @
ebd1b1dc
...
...
@@ -3278,16 +3278,18 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
self
.
assertEqual
(
dt
.
astimezone
(
None
),
dt
)
self
.
assertEqual
(
dt
.
astimezone
(),
dt
)
# Note that offset in TZ variable has the opposite sign to that
# produced by %z directive.
@
support
.
run_with_tz
(
'EST+05EDT,M3.2.0,M11.1.0'
)
def
test_astimezone_default_eastern
(
self
):
dt
=
self
.
theclass
(
2012
,
11
,
4
,
6
,
30
,
tzinfo
=
timezone
.
utc
)
local
=
dt
.
astimezone
()
self
.
assertEqual
(
dt
,
local
)
self
.
assertEqual
(
local
.
strftime
(
"%z %Z"
),
"
+
0500 EST"
)
self
.
assertEqual
(
local
.
strftime
(
"%z %Z"
),
"
-
0500 EST"
)
dt
=
self
.
theclass
(
2012
,
11
,
4
,
5
,
30
,
tzinfo
=
timezone
.
utc
)
local
=
dt
.
astimezone
()
self
.
assertEqual
(
dt
,
local
)
self
.
assertEqual
(
local
.
strftime
(
"%z %Z"
),
"
+
0400 EDT"
)
self
.
assertEqual
(
local
.
strftime
(
"%z %Z"
),
"
-
0400 EDT"
)
def
test_aware_subtract
(
self
):
cls
=
self
.
theclass
...
...
Lib/test/test_capi.py
View file @
ebd1b1dc
...
...
@@ -222,36 +222,38 @@ class SkipitemTest(unittest.TestCase):
in Python/getargs.c, but neglected to update our poor friend
skipitem() in the same file. (If so, shame on you!)
This function brute-force tests all** ASCII characters (1 to 127
inclusive) as format units, checking to see that
PyArg_ParseTupleAndKeywords() return consistent errors both when
the unit is attempted to be used and when it is skipped. If the
format unit doesn't exist, we'll get one of two specific error
messages (one for used, one for skipped); if it does exist we
*won't* get that error--we'll get either no error or some other
error. If we get the "does not exist" error for one test and
not for the other, there's a mismatch, and the test fails.
** Okay, it actually skips some ASCII characters. Some characters
have special funny semantics, and it would be difficult to
accomodate them here.
With a few exceptions**, this function brute-force tests all
printable ASCII*** characters (32 to 126 inclusive) as format units,
checking to see that PyArg_ParseTupleAndKeywords() return consistent
errors both when the unit is attempted to be used and when it is
skipped. If the format unit doesn't exist, we'll get one of two
specific error messages (one for used, one for skipped); if it does
exist we *won't* get that error--we'll get either no error or some
other error. If we get the specific "does not exist" error for one
test and not for the other, there's a mismatch, and the test fails.
** Some format units have special funny semantics and it would
be difficult to accomodate them here. Since these are all
well-established and properly skipped in skipitem() we can
get away with not testing them--this test is really intended
to catch *new* format units.
*** Python C source files must be ASCII. Therefore it's impossible
to have non-ASCII format units.
"""
empty_tuple
=
()
tuple_1
=
(
0
,)
dict_b
=
{
'b'
:
1
}
keywords
=
[
"a"
,
"b"
]
# Python C source files must be ASCII,
# therefore we'll never have a format unit > 127
for
i
in
range
(
1
,
128
):
for
i
in
range
(
32
,
127
):
c
=
chr
(
i
)
# skip non-printable characters, no one is insane enough to define
# one as a format unit
# skip parentheses, the error reporting is inconsistent about them
# skip 'e', it's always a two-character code
# skip '|' and '$', they don't represent arguments anyway
if
(
not
c
.
isprintable
())
or
(
c
in
'()e|$'
)
:
if
c
in
'()e|$'
:
continue
# test the format unit when not skipped
...
...
Modules/_datetimemodule.c
View file @
ebd1b1dc
...
...
@@ -4717,12 +4717,8 @@ local_timezone(PyDateTime_DateTime *utc_time)
return
NULL
;
timep
=
localtime
(
&
timestamp
);
#ifdef HAVE_STRUCT_TM_TM_ZONE
{
long
offset
;
offset
=
timep
->
tm_gmtoff
;
zone
=
timep
->
tm_zone
;
delta
=
new_delta
(
0
,
-
offset
,
0
,
0
);
}
zone
=
timep
->
tm_zone
;
delta
=
new_delta
(
0
,
timep
->
tm_gmtoff
,
0
,
1
);
#else
/* HAVE_STRUCT_TM_TM_ZONE */
{
PyObject
*
local_time
;
...
...
@@ -4732,7 +4728,7 @@ local_timezone(PyDateTime_DateTime *utc_time)
utc_time
->
tzinfo
);
if
(
local_time
==
NULL
)
goto
error
;
delta
=
datetime_subtract
(
(
PyObject
*
)
utc_time
,
local
_time
);
delta
=
datetime_subtract
(
local_time
,
(
PyObject
*
)
utc
_time
);
/* XXX: before relying on tzname, we should compare delta
to the offset implied by timezone/altzone */
if
(
daylight
&&
timep
->
tm_isdst
>=
0
)
...
...
Tools/ssl/make_ssl_data.py
View file @
ebd1b1dc
#! /usr/bin/env python3
"""
This script should be called *manually* when we want to upgrade SSLError
`library` and `reason` mnemnonics to a more recent OpenSSL version.
It takes two arguments:
- the path to the OpenSSL include files' directory
(e.g. openssl-1.0.1-beta3/include/openssl/)
- the path to the C file to be generated
(probably Modules/_ssl_data.h)
"""
import
datetime
import
os
import
re
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment