Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 139
    • Merge requests 139
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !275

Merged
Created May 24, 2017 by Tatuya Kamada@tatuyaContributor

Restricted: Allow datetime module class attributes.

  • Overview 15
  • Commits 1
  • Changes 2

Restricted: Allow datetime module class attributes.

To allow the class attributes, we add a helper method ``allow_class_attribute''. Why addng this is because allow_module can allow instance methods but not class attributes. For example, datetime.datetime.now(), datetime.datetime.max, dict.fromkeys(), Decimal.from_float(), epoll.fromfd(), itertools.chain.from_iterable() are class attributes in Python 2.7.

Also, add a special in-advance-import for datetime.datetime.strptime(). It is because datetime.datetime.strptime() imports _strptime by C function PyImport_Import which calls import(name, globals, locals, fromlist=['doc'], level=0). The "level=0" is not supported by AccessControl in Zope2. At the same time, the dummy from 'doc' is neither allowed in it by default. Therefore we import _strptime in advance in this monkey patch file. This prevents both importing _strptime with level=0, and accessing doc, when calling datetime.datetime.strptime() in Restricted environment.

/cc @vpelletier @jm @klaus

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: allow_datetime_class_attributes
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7