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

datetime types don't work as bases #38298

Closed
tim-one opened this issue Apr 14, 2003 · 6 comments
Closed

datetime types don't work as bases #38298

tim-one opened this issue Apr 14, 2003 · 6 comments
Assignees
Labels
extension-modules C modules in the Modules dir

Comments

@tim-one
Copy link
Member

tim-one commented Apr 14, 2003

BPO 720908
Nosy @gvanrossum, @tim-one
Files
  • datetime.fix: Strawman fix
  • 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:

    assignee = 'https://github.com/tim-one'
    closed_at = <Date 2003-05-17.17:40:01.000>
    created_at = <Date 2003-04-14.04:58:53.000>
    labels = ['extension-modules']
    title = "datetime types don't work as bases"
    updated_at = <Date 2003-05-17.17:40:01.000>
    user = 'https://github.com/tim-one'

    bugs.python.org fields:

    activity = <Date 2003-05-17.17:40:01.000>
    actor = 'tim.peters'
    assignee = 'tim.peters'
    closed = True
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2003-04-14.04:58:53.000>
    creator = 'tim.peters'
    dependencies = []
    files = ['838']
    hgrepos = []
    issue_num = 720908
    keywords = []
    message_count = 6.0
    messages = ['15446', '15447', '15448', '15449', '15450', '15451']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'tim.peters']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue720908'
    versions = ['Python 2.3']

    @tim-one
    Copy link
    Member Author

    tim-one commented Apr 14, 2003

    This is probably shallow. Assigned to Guido in case
    it's very shallow <wink>:

    >>> from datetime import *
    >>> class C(date):
    ...     def whatever(self):
    ...         return "oops"
    >>> c = C(2002, 1, 1)
    >>> c.whatever()
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    AttributeError: 'datetime.date' object has no 
    attribute 'whatever'
    >>> type(c)
    <type 'datetime.date'>
    >>>

    Was reported on c.l.py.

    @tim-one tim-one closed this as completed Apr 14, 2003
    @tim-one tim-one self-assigned this Apr 14, 2003
    @tim-one tim-one added the extension-modules C modules in the Modules dir label Apr 14, 2003
    @tim-one tim-one closed this as completed Apr 14, 2003
    @tim-one tim-one self-assigned this Apr 14, 2003
    @tim-one tim-one added the extension-modules C modules in the Modules dir label Apr 14, 2003
    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Well, one shallow thing becomes obvious when you write
    c.__class__: it's date, not C! Back to Tim...

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Here's a strawman fix. It makes 'date' a properly
    subclassable type, and makes all the other types (except
    tzinfo) non-subclassable.

    @tim-one
    Copy link
    Member Author

    tim-one commented Apr 14, 2003

    Logged In: YES
    user_id=31435

    I think the date enhancement is fine -- check it in! I'd leave off
    removing the basetype flag on the other types, though -- I
    expect we'll need to make them subclassable too.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Done; the rest is up to you!

    @tim-one
    Copy link
    Member Author

    tim-one commented May 17, 2003

    Logged In: YES
    user_id=31435

    I checked in changes (for 2.3b2) so that time, datetime,
    and timedelta are properly subclassable from Python too.
    That's all of 'em, so closing this now.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants