This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fail on datetime import if _datetime.py exists in PATH
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mmckerns, vstinner
Priority: normal Keywords:

Created on 2020-01-06 14:56 by mmckerns, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg359429 - (view) Author: (mmckerns) Date: 2020-01-06 14:56
In Lib/datetime.py, there's an import: `from _datetime import *`
which will fail if `_datetime.py` exists in the current directory, or earlier in the path than Lib.  For reference, see:
https://github.com/numpy/numpy/issues/15257
msg359431 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-06 15:21
This issue is not a bug. You should not use the same module name, than a stdlib module. For example, if you have a "sys.py" file in your Python path (PYTHONPATH), you will get big troubles.
msg359442 - (view) Author: (mmckerns) Date: 2020-01-06 18:03
Sure, that's obvious for `datetime` and `sys`.  Less obvious for unexpected conflicts with stdlib modules that begin with an underscore...
msg359475 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-06 22:25
> Sure, that's obvious for `datetime` and `sys`.  Less obvious for unexpected conflicts with stdlib modules that begin with an underscore...

Yeah, sadly, these modules are less known, but cause the same kind of issues :-(
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83411
2020-01-06 22:25:17vstinnersetmessages: + msg359475
2020-01-06 18:03:29mmckernssetmessages: + msg359442
2020-01-06 15:21:33vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg359431

resolution: not a bug
stage: resolved
2020-01-06 14:56:11mmckernscreate