{
    "file_diffs": [
        {
            "old_file_content": "Next release\n============\n\nFeatures\n--------\n\n- Add a ``handler`` ZCML directive.  This directive does the same thing as\n  ``pyramid.configuration.add_handler``.\n\n- A new module named ``pyramid.config`` was added.  It subsumes the duties of\n  the older ``pyramid.configuration`` module.\n\n- The new ``pyramid.config.Configurator` class has API methods that the older\n  ``pyramid.configuration.Configurator`` class did not: ``with_context`` (a\n  classmethod), ``include``, ``action``, and ``commit``.  These methods exist\n  for imperative application extensibility purposes.\n\n- The ``pyramid.testing.setUp`` function now accepts an ``autocommit``\n  keyword argument, which defaults to ``True``.  If it is passed ``False``,\n  the Config object returned by ``setUp`` will be a non-autocommiting Config\n  object.\n\n- Add logging configuration to all paster templates.\n\n- ``pyramid_alchemy``, ``pyramid_routesalchemy``, and ``pylons_sqla`` paster\n  templates now use idiomatic SQLAlchemy configuration in their respective\n  ``.ini`` files and Python code.\n\n- ``pyramid.testing.DummyRequest`` now has a class variable,\n  ``query_string``, which defaults to the empty string.\n\n- Add support for json on GAE by catching NotImplementedError and importing\n  simplejson from django.utils.\n\n- The Mako renderer now accepts a resource specification for\n  ``mako.module_directory``.\n\n- New boolean Mako settings variable ``mako.strict_undefined``.  See `Mako\n  Context Variables\n  <http://www.makotemplates.org/docs/runtime.html#context-variables>`_ for\n  its meaning.\n\nDependencies\n------------\n\n- Depend on Mako 0.3.6+ (we now require the ``strict_undefined`` feature).\n\nBug Fixes\n---------\n\n- The ``pyramid_routesalchemy`` paster template's unit tests failed\n  (``AssertionError: 'SomeProject' != 'someproject'``).  This is fixed.\n\n- Make default renderer work (renderer factory registered with no name, which\n  is active for every view unless the view names a specific renderer).\n\n- The Mako renderer did not properly turn the ``mako.imports``,\n  ``mako.default_filters``, and ``mako.imports`` settings into lists.\n\n- The Mako renderer did not properly convert the ``mako.error_handler``\n  setting from a dotted name to a callable.\n\nDocumentation\n-------------\n\n- \"Sample Applications\" section of docs changed to note existence of Cluegun,\n  Shootout and Virginia sample applications, ported from their repoze.bfg\n  origin packages.\n\n- SQLAlchemy+URLDispatch tutorial updated to integrate changes to\n  ``pyramid_routesalchemy`` template.\n\n- Add ``pyramid.interfaces.ITemplateRenderer`` interface to Interfaces API\n  chapter (has ``implementation()`` method, required to be used when getting\n  at Chameleon macros).\n\n- Add a \"Modifying Package Structure\" section to the project narrative\n  documentation chapter (explain turning a module into a package).\n\n- Documentation was added for the new ``handler`` ZCML directive in the ZCML\n  section.\n\nDeprecations\n------------\n\n- ``pyramid.configuration.Configurator`` is now deprecated.  Use\n  ``pyramid.config.Configurator``, passing its constructor\n  ``autocommit=True`` instead.  The ``pyramid.configuration.Configurator``\n  alias will live for a long time, as every application uses it, but its\n  import now issues a deprecation warning.  The\n  ``pyramid.config.Configurator`` class has the same API as\n  ``pyramid.configuration.Configurator`` class, which it means to replace,\n  except by default it is a *non-autocommitting* configurator. The\n  now-deprecated ``pyramid.configuration.Configurator`` will autocommit every\n  time a configuration method is called.\n\n  The ``pyramid.configuration`` module remains, but it is deprecated.  Use\n  ``pyramid.config`` instead.\n\n1.0a4 (2010-11-21)\n==================\n\nFeatures\n--------\n\n- URL Dispatch now allows for replacement markers to be located anywhere\n  in the pattern, instead of immediately following a ``/``.\n\n- URL Dispatch now uses the form ``{marker}`` to denote a replace marker in\n  the route pattern instead of ``:marker``. The old colon-style marker syntax\n  is still accepted for backwards compatibility. The new format allows a\n  regular expression for that marker location to be used instead of the\n  default ``[^/]+``, for example ``{marker:\\d+}`` is now valid to require the\n  marker to be digits.\n\n- Add a ``pyramid.url.route_path`` API, allowing folks to generate relative\n  URLs.  Calling ``route_path`` is the same as calling\n  ``pyramid.url.route_url`` with the argument ``_app_url`` equal to the empty\n  string.\n\n- Add a ``pyramid.request.Request.route_path`` API.  This is a convenience\n  method of the request which calls ``pyramid.url.route_url``.\n\n- Make test suite pass on Jython (requires PasteScript trunk, presumably to\n  be 1.7.4).\n\n- Make test suite pass on PyPy (Chameleon doesn't work).\n\n- Surrounding application configuration with ``config.begin()`` and\n  ``config.end()`` is no longer necessary.  All paster templates have been\n  changed to no longer call these functions.\n\n- Fix configurator to not convert ``ImportError`` to ``ConfigurationError``\n  if the import that failed was unrelated to the import requested via a\n  dotted name when resolving dotted names (such as view dotted names).\n\nDocumentation\n-------------\n\n- SQLAlchemy+URLDispatch and ZODB+Traversal tutorials have been updated to\n  not call ``config.begin()`` or ``config.end()``.\n\nBug Fixes\n---------\n\n- Add deprecation warnings to import of ``pyramid.chameleon_text`` and\n  ``pyramid.chameleon_zpt`` of ``get_renderer``, ``get_template``,\n  ``render_template``, and ``render_template_to_response``.\n\n- Add deprecation warning for import of ``pyramid.zcml.zcml_configure`` and\n  ``pyramid.zcml.file_configure``.\n\n- The ``pyramid_alchemy`` paster template had a typo, preventing an import\n  from working.\n\n- Fix apparent failures when calling ``pyramid.traversal.find_model(root,\n  path)`` or ``pyramid.traversal.traverse(path)`` when ``path`` is\n  (erroneously) a Unicode object. The user is meant to pass these APIs a\n  string object, never a Unicode object.  In practice, however, users indeed\n  pass Unicode.  Because the string that is passed must be ASCII encodeable,\n  now, if they pass a Unicode object, its data is eagerly converted to an\n  ASCII string rather than being passed along to downstream code as a\n  convenience to the user and to prevent puzzling second-order failures from\n  cropping up (all failures will occur within ``pyramid.traversal.traverse``\n  rather than later down the line as the result of calling e.g.\n  ``traversal_path``).\n\nBackwards Incompatibilities\n---------------------------\n\n- The ``pyramid.testing.zcml_configure`` API has been removed.  It had been\n  advertised as removed since repoze.bfg 1.2a1, but hadn't actually been.\n\nDeprecations\n------------\n\n- The ``pyramid.settings.get_settings`` API is now deprecated.  Use\n  ``pyramid.threadlocals.get_current_registry().settings`` instead or use the\n  ``settings`` attribute of the registry available from the request\n  (``request.registry.settings``).\n\nDocumentation\n-------------\n\n- Removed ``zodbsessions`` tutorial chapter.  It's still useful, but we now\n  have a SessionFactory abstraction which competes with it, and maintaining\n  documentation on both ways to do it is a distraction.\n\nInternal\n--------\n\n- Replace Twill with WebTest in internal integration tests (avoid deprecation\n  warnings generated by Twill).\n\n1.0a3 (2010-11-16)\n==================\n\nFeatures\n--------\n\n- Added Mako TemplateLookup settings for ``mako.error_handler``,\n  ``mako.default_filters``, and ``mako.imports``.\n\n- Normalized all paster templates: each now uses the name ``main`` to\n  represent the function that returns a WSGI application, each now uses\n  WebError, each now has roughly the same shape of development.ini style.\n\n- Added class vars ``matchdict`` and ``matched_route`` to\n  ``pyramid.request.Request``.  Each is set to ``None``.\n\n- New API method: ``pyramid.settings.asbool``.\n\n- New API methods for ``pyramid.request.Request``: ``model_url``,\n  ``route_url``, and ``static_url``.  These are simple passthroughs for their\n  respective functions in ``pyramid.url``.\n\n- The ``settings`` object which used to be available only when\n  ``request.settings.get_settings`` was called is now available as\n  ``registry.settings`` (e.g. ``request.registry.settings`` in view code).\n\nBug Fixes\n---------\n\n- The pylons_* paster templates erroneously used the ``{squiggly}`` routing\n  syntax as the pattern supplied to ``add_route``.  This style of routing is\n  not supported.  They were replaced with ``:colon`` style route patterns.\n\n- The pylons_* paster template used the same string\n  (``your_app_secret_string``) for the ``session.secret`` setting in the\n  generated ``development.ini``.  This was a security risk if left unchanged\n  in a project that used one of the templates to produce production\n  applications.  It now uses a randomly generated string.\n\nDocumentation\n-------------\n\n- ZODB+traversal wiki (``wiki``) tutorial updated due to changes to\n  ``pyramid_zodb`` paster template.\n\n- SQLAlchemy+urldispach wiki (``wiki2``) tutorial updated due to changes to\n  ``pyramid_routesalchemy`` paster template.\n\n- Documented the ``matchdict`` and ``matched_route`` attributes of the\n  request object in the Request API documentation.\n\nDeprecations\n------------\n\n- Obtaining the ``settings`` object via\n  ``registry.{get|query}Utility(ISettings)`` is now deprecated.  Instead,\n  obtain the ``settings`` object via the ``registry.settings`` attribute.  A\n  backwards compatibility shim was added to the registry object to register\n  the settings object as an ISettings utility when ``setattr(registry,\n  'settings', foo)`` is called, but it will be removed in a later release.\n\n- Obtaining the ``settings`` object via ``pyramid.settings.get_settings`` is\n  now deprecated.  Obtain it as the ``settings`` attribute of the registry\n  now (obtain the registry via ``pyramid.threadlocal.get_registry`` or as\n  ``request.registry``).\n\nBehavior Differences\n--------------------\n\n- Internal: ZCML directives no longer call get_current_registry() if there's\n  a ``registry`` attribute on the ZCML context (kill off use of\n  threadlocals).\n\n- Internal: Chameleon template renderers now accept two arguments: ``path``\n  and ``lookup``.  ``Lookup`` will be an instance of a lookup class which\n  supplies (late-bound) arguments for debug, reload, and translate.  Any\n  third-party renderers which use (the non-API) function\n  ``pyramid.renderers.template_renderer_factory`` will need to adjust their\n  implementations to obey the new callback argument list.  This change was to\n  kill off inappropriate use of threadlocals.\n\n1.0a2 (2010-11-09)\n==================\n\nDocumentation\n-------------\n\n- All references to events by interface\n  (e.g. ``pyramid.interfaces.INewRequest``) have been changed to reference\n  their concrete classes (e.g. ``pyramid.events.NewRequest``) in\n  documentation about making subscriptions.\n\n- All references to Pyramid-the-application were changed from mod-`pyramid`\n  to app-`Pyramid`.  A custom role setting was added to ``docs/conf.py`` to\n  allow for this.  (internal)\n\n1.0a1 (2010-11-05)\n==================\n\nFeatures (delta from BFG 1.3)\n-------------------------------\n\n- Mako templating renderer supports resource specification format for\n  template lookups and within Mako templates. Absolute filenames must\n  be used in Pyramid to avoid this lookup process.\n\n- Add ``pyramid.httpexceptions`` module, which is a facade for the\n  ``webob.exc`` module.\n\n- Direct built-in support for the Mako templating language.\n\n- A new configurator method exists: ``add_handler``.  This method adds\n  a Pylons-style \"view handler\" (such a thing used to be called a\n  \"controller\" in Pylons 1.0).\n\n- New argument to configurator: ``session_factory``.\n\n- New method on configurator: ``set_session_factory``\n\n- Using ``request.session`` now returns a (dictionary-like) session\n  object if a session factory has been configured.\n\n- The request now has a new attribute: ``tmpl_context`` for benefit of\n  Pylons users.\n\n- The decorator previously known as ``pyramid.view.bfg_view`` is now\n  known most formally as ``pyramid.view.view_config`` in docs and\n  paster templates.  An import of ``pyramid.view.bfg_view``, however,\n  will continue to work \"forever\".\n\n- New API methods in ``pyramid.session``: ``signed_serialize`` and\n  ``signed_deserialize``.\n\n- New interface: ``pyramid.interfaces.IRendererInfo``.  An object of this type\n  is passed to renderer factory constructors (see \"Backwards\n  Incompatibilities\").\n\n- New event type: ``pyramid.interfaces.IBeforeRender``.  An object of this type\n  is sent as an event before a renderer is invoked (but after the\n  application-level renderer globals factory added via\n  ``pyramid.configurator.configuration.set_renderer_globals_factory``, if any,\n  has injected its own keys).  Applications may now subscribe to the\n  ``IBeforeRender`` event type in order to introspect the and modify the set of\n  renderer globals before they are passed to a renderer.  The event object\n  iself has a dictionary-like interface that can be used for this purpose.  For\n  example::\n\n    from repoze.events import subscriber\n    from pyramid.interfaces import IRendererGlobalsEvent\n\n    @subscriber(IRendererGlobalsEvent)\n    def add_global(event):\n        event['mykey'] = 'foo'\n\n  If a subscriber attempts to add a key that already exist in the renderer\n  globals dictionary, a ``KeyError`` is raised.  This limitation is due to the\n  fact that subscribers cannot be ordered relative to each other.  The set of\n  keys added to the renderer globals dictionary by all subscribers and\n  app-level globals factories must be unique.\n\n- New class: ``pyramid.response.Response``.  This is a pure facade for\n  ``webob.Response`` (old code need not change to use this facade, it's\n  existence is mostly for vanity and documentation-generation purposes).\n\n- All preexisting paster templates (except ``zodb``) now use \"imperative\"\n  configuration (``starter``, ``routesalchemy``, ``alchemy``).\n\n- A new paster template named ``pyramid_starter_zcml`` exists, which uses\n  declarative configuration.\n\nDocumentation (delta from BFG 1.3)\n-----------------------------------\n\n- Added a ``pyramid.httpexceptions`` API documentation chapter.\n\n- Added a ``pyramid.session`` API documentation chapter.\n\n- Added a ``Session Objects`` narrative documentation chapter.\n\n- Added an API chapter for the ``pyramid.personality`` module.\n\n- Added an API chapter for the ``pyramid.response`` module.\n\n- All documentation which previously referred to ``webob.Response`` now uses\n  ``pyramid.response.Response`` instead.\n\n- The documentation has been overhauled to use imperative configuration,\n  moving declarative configuration (ZCML) explanations to a separate\n  narrative chapter ``declarative.rst``.\n\n- The ZODB Wiki tutorial was updated to take into account changes to the\n  ``pyramid_zodb`` paster template.\n\n- The SQL Wiki tutorial was updated to take into account changes to the\n  ``pyramid_routesalchemy`` paster template.\n\nBackwards Incompatibilities (with BFG 1.3)\n------------------------------------------\n\n- There is no longer an ``IDebugLogger`` registered as a named utility\n  with the name ``repoze.bfg.debug``.\n\n- The logger which used to have the name of ``repoze.bfg.debug`` now\n  has the name ``pyramid.debug``.\n\n- The deprecated API ``pyramid.testing.registerViewPermission``\n  has been removed.\n\n- The deprecated API named ``pyramid.testing.registerRoutesMapper``\n  has been removed.\n\n- The deprecated API named ``pyramid.request.get_request`` was removed.\n\n- The deprecated API named ``pyramid.security.Unauthorized`` was\n  removed.\n\n- The deprecated API named ``pyramid.view.view_execution_permitted``\n  was removed.\n\n- The deprecated API named ``pyramid.view.NotFound`` was removed.\n\n- The ``bfgshell`` paster command is now named ``pshell``.\n\n- The Venusian \"category\" for all built-in Venusian decorators\n  (e.g. ``subscriber`` and ``view_config``/``bfg_view``) is now\n  ``pyramid`` instead of ``bfg``.\n\n- ``pyramid.renderers.rendered_response`` function removed; use\n  ``render_pyramid.renderers.render_to_response`` instead.\n\n- Renderer factories now accept a *renderer info object* rather than an\n  absolute resource specification or an absolute path.  The object has the\n  following attributes: ``name`` (the ``renderer=`` value), ``package`` (the\n  'current package' when the renderer configuration statement was found),\n  ``type``: the renderer type, ``registry``: the current registry, and\n  ``settings``: the deployment settings dictionary.\n\n  Third-party ``repoze.bfg`` renderer implementations that must be ported to\n  Pyramid will need to account for this.\n\n  This change was made primarily to support more flexible Mako template\n  rendering.\n\n- The presence of the key ``repoze.bfg.message`` in the WSGI environment when\n  an exception occurs is now deprecated.  Instead, code which relies on this\n  environ value should use the ``exception`` attribute of the request\n  (e.g. ``request.exception[0]``) to retrieve the message.\n\n- The values ``bfg_localizer`` and ``bfg_locale_name`` kept on the request\n  during internationalization for caching purposes were never APIs.  These\n  however have changed to ``localizer`` and ``locale_name``, respectively.\n\n- The default ``cookie_name`` value of the ``authtktauthenticationpolicy`` ZCML\n  now defaults to ``auth_tkt`` (it used to default to ``repoze.bfg.auth_tkt``).\n\n- The default ``cookie_name`` value of the\n  ``pyramid.authentication.AuthTktAuthenticationPolicy`` constructor now\n  defaults to ``auth_tkt`` (it used to default to ``repoze.bfg.auth_tkt``).\n\n- The ``request_type`` argument to the ``view`` ZCML directive, the\n  ``pyramid.configuration.Configurator.add_view`` method, or the\n  ``pyramid.view.view_config`` decorator (nee ``bfg_view``) is no longer\n  permitted to be one of the strings ``GET``, ``HEAD``, ``PUT``, ``POST`` or\n  ``DELETE``, and now must always be an interface.  Accepting the\n  method-strings as ``request_type`` was a backwards compatibility strategy\n  servicing repoze.bfg 1.0 applications.  Use the ``request_method``\n  parameter instead to specify that a view a string request-method predicate.\n",
            "new_file_content": "Next release\n============\n\nFeatures\n--------\n\n- Add a ``handler`` ZCML directive.  This directive does the same thing as\n  ``pyramid.configuration.add_handler``.\n\n- A new module named ``pyramid.config`` was added.  It subsumes the duties of\n  the older ``pyramid.configuration`` module.\n\n- The new ``pyramid.config.Configurator` class has API methods that the older\n  ``pyramid.configuration.Configurator`` class did not: ``with_context`` (a\n  classmethod), ``include``, ``action``, and ``commit``.  These methods exist\n  for imperative application extensibility purposes.\n\n- The ``pyramid.testing.setUp`` function now accepts an ``autocommit``\n  keyword argument, which defaults to ``True``.  If it is passed ``False``,\n  the Config object returned by ``setUp`` will be a non-autocommiting Config\n  object.\n\n- Add logging configuration to all paster templates.\n\n- ``pyramid_alchemy``, ``pyramid_routesalchemy``, and ``pylons_sqla`` paster\n  templates now use idiomatic SQLAlchemy configuration in their respective\n  ``.ini`` files and Python code.\n\n- ``pyramid.testing.DummyRequest`` now has a class variable,\n  ``query_string``, which defaults to the empty string.\n\n- Add support for json on GAE by catching NotImplementedError and importing\n  simplejson from django.utils.\n\n- The Mako renderer now accepts a resource specification for\n  ``mako.module_directory``.\n\n- New boolean Mako settings variable ``mako.strict_undefined``.  See `Mako\n  Context Variables\n  <http://www.makotemplates.org/docs/runtime.html#context-variables>`_ for\n  its meaning.\n\nDependencies\n------------\n\n- Depend on Mako 0.3.6+ (we now require the ``strict_undefined`` feature).\n\nBug Fixes\n---------\n\n- When creating a Configurator from within a ``paster pshell`` session, you\n  were required to pass a ``package`` argument although ``package`` is not\n  actually required.  If you didn't pass ``package``, you would receive an\n  error something like ``KeyError: '__name__'`` emanating from the\n  ``pyramid.path.caller_module`` function.  This has now been fixed.\n\n- The ``pyramid_routesalchemy`` paster template's unit tests failed\n  (``AssertionError: 'SomeProject' != 'someproject'``).  This is fixed.\n\n- Make default renderer work (renderer factory registered with no name, which\n  is active for every view unless the view names a specific renderer).\n\n- The Mako renderer did not properly turn the ``mako.imports``,\n  ``mako.default_filters``, and ``mako.imports`` settings into lists.\n\n- The Mako renderer did not properly convert the ``mako.error_handler``\n  setting from a dotted name to a callable.\n\nDocumentation\n-------------\n\n- \"Sample Applications\" section of docs changed to note existence of Cluegun,\n  Shootout and Virginia sample applications, ported from their repoze.bfg\n  origin packages.\n\n- SQLAlchemy+URLDispatch tutorial updated to integrate changes to\n  ``pyramid_routesalchemy`` template.\n\n- Add ``pyramid.interfaces.ITemplateRenderer`` interface to Interfaces API\n  chapter (has ``implementation()`` method, required to be used when getting\n  at Chameleon macros).\n\n- Add a \"Modifying Package Structure\" section to the project narrative\n  documentation chapter (explain turning a module into a package).\n\n- Documentation was added for the new ``handler`` ZCML directive in the ZCML\n  section.\n\nDeprecations\n------------\n\n- ``pyramid.configuration.Configurator`` is now deprecated.  Use\n  ``pyramid.config.Configurator``, passing its constructor\n  ``autocommit=True`` instead.  The ``pyramid.configuration.Configurator``\n  alias will live for a long time, as every application uses it, but its\n  import now issues a deprecation warning.  The\n  ``pyramid.config.Configurator`` class has the same API as\n  ``pyramid.configuration.Configurator`` class, which it means to replace,\n  except by default it is a *non-autocommitting* configurator. The\n  now-deprecated ``pyramid.configuration.Configurator`` will autocommit every\n  time a configuration method is called.\n\n  The ``pyramid.configuration`` module remains, but it is deprecated.  Use\n  ``pyramid.config`` instead.\n\n1.0a4 (2010-11-21)\n==================\n\nFeatures\n--------\n\n- URL Dispatch now allows for replacement markers to be located anywhere\n  in the pattern, instead of immediately following a ``/``.\n\n- URL Dispatch now uses the form ``{marker}`` to denote a replace marker in\n  the route pattern instead of ``:marker``. The old colon-style marker syntax\n  is still accepted for backwards compatibility. The new format allows a\n  regular expression for that marker location to be used instead of the\n  default ``[^/]+``, for example ``{marker:\\d+}`` is now valid to require the\n  marker to be digits.\n\n- Add a ``pyramid.url.route_path`` API, allowing folks to generate relative\n  URLs.  Calling ``route_path`` is the same as calling\n  ``pyramid.url.route_url`` with the argument ``_app_url`` equal to the empty\n  string.\n\n- Add a ``pyramid.request.Request.route_path`` API.  This is a convenience\n  method of the request which calls ``pyramid.url.route_url``.\n\n- Make test suite pass on Jython (requires PasteScript trunk, presumably to\n  be 1.7.4).\n\n- Make test suite pass on PyPy (Chameleon doesn't work).\n\n- Surrounding application configuration with ``config.begin()`` and\n  ``config.end()`` is no longer necessary.  All paster templates have been\n  changed to no longer call these functions.\n\n- Fix configurator to not convert ``ImportError`` to ``ConfigurationError``\n  if the import that failed was unrelated to the import requested via a\n  dotted name when resolving dotted names (such as view dotted names).\n\nDocumentation\n-------------\n\n- SQLAlchemy+URLDispatch and ZODB+Traversal tutorials have been updated to\n  not call ``config.begin()`` or ``config.end()``.\n\nBug Fixes\n---------\n\n- Add deprecation warnings to import of ``pyramid.chameleon_text`` and\n  ``pyramid.chameleon_zpt`` of ``get_renderer``, ``get_template``,\n  ``render_template``, and ``render_template_to_response``.\n\n- Add deprecation warning for import of ``pyramid.zcml.zcml_configure`` and\n  ``pyramid.zcml.file_configure``.\n\n- The ``pyramid_alchemy`` paster template had a typo, preventing an import\n  from working.\n\n- Fix apparent failures when calling ``pyramid.traversal.find_model(root,\n  path)`` or ``pyramid.traversal.traverse(path)`` when ``path`` is\n  (erroneously) a Unicode object. The user is meant to pass these APIs a\n  string object, never a Unicode object.  In practice, however, users indeed\n  pass Unicode.  Because the string that is passed must be ASCII encodeable,\n  now, if they pass a Unicode object, its data is eagerly converted to an\n  ASCII string rather than being passed along to downstream code as a\n  convenience to the user and to prevent puzzling second-order failures from\n  cropping up (all failures will occur within ``pyramid.traversal.traverse``\n  rather than later down the line as the result of calling e.g.\n  ``traversal_path``).\n\nBackwards Incompatibilities\n---------------------------\n\n- The ``pyramid.testing.zcml_configure`` API has been removed.  It had been\n  advertised as removed since repoze.bfg 1.2a1, but hadn't actually been.\n\nDeprecations\n------------\n\n- The ``pyramid.settings.get_settings`` API is now deprecated.  Use\n  ``pyramid.threadlocals.get_current_registry().settings`` instead or use the\n  ``settings`` attribute of the registry available from the request\n  (``request.registry.settings``).\n\nDocumentation\n-------------\n\n- Removed ``zodbsessions`` tutorial chapter.  It's still useful, but we now\n  have a SessionFactory abstraction which competes with it, and maintaining\n  documentation on both ways to do it is a distraction.\n\nInternal\n--------\n\n- Replace Twill with WebTest in internal integration tests (avoid deprecation\n  warnings generated by Twill).\n\n1.0a3 (2010-11-16)\n==================\n\nFeatures\n--------\n\n- Added Mako TemplateLookup settings for ``mako.error_handler``,\n  ``mako.default_filters``, and ``mako.imports``.\n\n- Normalized all paster templates: each now uses the name ``main`` to\n  represent the function that returns a WSGI application, each now uses\n  WebError, each now has roughly the same shape of development.ini style.\n\n- Added class vars ``matchdict`` and ``matched_route`` to\n  ``pyramid.request.Request``.  Each is set to ``None``.\n\n- New API method: ``pyramid.settings.asbool``.\n\n- New API methods for ``pyramid.request.Request``: ``model_url``,\n  ``route_url``, and ``static_url``.  These are simple passthroughs for their\n  respective functions in ``pyramid.url``.\n\n- The ``settings`` object which used to be available only when\n  ``request.settings.get_settings`` was called is now available as\n  ``registry.settings`` (e.g. ``request.registry.settings`` in view code).\n\nBug Fixes\n---------\n\n- The pylons_* paster templates erroneously used the ``{squiggly}`` routing\n  syntax as the pattern supplied to ``add_route``.  This style of routing is\n  not supported.  They were replaced with ``:colon`` style route patterns.\n\n- The pylons_* paster template used the same string\n  (``your_app_secret_string``) for the ``session.secret`` setting in the\n  generated ``development.ini``.  This was a security risk if left unchanged\n  in a project that used one of the templates to produce production\n  applications.  It now uses a randomly generated string.\n\nDocumentation\n-------------\n\n- ZODB+traversal wiki (``wiki``) tutorial updated due to changes to\n  ``pyramid_zodb`` paster template.\n\n- SQLAlchemy+urldispach wiki (``wiki2``) tutorial updated due to changes to\n  ``pyramid_routesalchemy`` paster template.\n\n- Documented the ``matchdict`` and ``matched_route`` attributes of the\n  request object in the Request API documentation.\n\nDeprecations\n------------\n\n- Obtaining the ``settings`` object via\n  ``registry.{get|query}Utility(ISettings)`` is now deprecated.  Instead,\n  obtain the ``settings`` object via the ``registry.settings`` attribute.  A\n  backwards compatibility shim was added to the registry object to register\n  the settings object as an ISettings utility when ``setattr(registry,\n  'settings', foo)`` is called, but it will be removed in a later release.\n\n- Obtaining the ``settings`` object via ``pyramid.settings.get_settings`` is\n  now deprecated.  Obtain it as the ``settings`` attribute of the registry\n  now (obtain the registry via ``pyramid.threadlocal.get_registry`` or as\n  ``request.registry``).\n\nBehavior Differences\n--------------------\n\n- Internal: ZCML directives no longer call get_current_registry() if there's\n  a ``registry`` attribute on the ZCML context (kill off use of\n  threadlocals).\n\n- Internal: Chameleon template renderers now accept two arguments: ``path``\n  and ``lookup``.  ``Lookup`` will be an instance of a lookup class which\n  supplies (late-bound) arguments for debug, reload, and translate.  Any\n  third-party renderers which use (the non-API) function\n  ``pyramid.renderers.template_renderer_factory`` will need to adjust their\n  implementations to obey the new callback argument list.  This change was to\n  kill off inappropriate use of threadlocals.\n\n1.0a2 (2010-11-09)\n==================\n\nDocumentation\n-------------\n\n- All references to events by interface\n  (e.g. ``pyramid.interfaces.INewRequest``) have been changed to reference\n  their concrete classes (e.g. ``pyramid.events.NewRequest``) in\n  documentation about making subscriptions.\n\n- All references to Pyramid-the-application were changed from mod-`pyramid`\n  to app-`Pyramid`.  A custom role setting was added to ``docs/conf.py`` to\n  allow for this.  (internal)\n\n1.0a1 (2010-11-05)\n==================\n\nFeatures (delta from BFG 1.3)\n-------------------------------\n\n- Mako templating renderer supports resource specification format for\n  template lookups and within Mako templates. Absolute filenames must\n  be used in Pyramid to avoid this lookup process.\n\n- Add ``pyramid.httpexceptions`` module, which is a facade for the\n  ``webob.exc`` module.\n\n- Direct built-in support for the Mako templating language.\n\n- A new configurator method exists: ``add_handler``.  This method adds\n  a Pylons-style \"view handler\" (such a thing used to be called a\n  \"controller\" in Pylons 1.0).\n\n- New argument to configurator: ``session_factory``.\n\n- New method on configurator: ``set_session_factory``\n\n- Using ``request.session`` now returns a (dictionary-like) session\n  object if a session factory has been configured.\n\n- The request now has a new attribute: ``tmpl_context`` for benefit of\n  Pylons users.\n\n- The decorator previously known as ``pyramid.view.bfg_view`` is now\n  known most formally as ``pyramid.view.view_config`` in docs and\n  paster templates.  An import of ``pyramid.view.bfg_view``, however,\n  will continue to work \"forever\".\n\n- New API methods in ``pyramid.session``: ``signed_serialize`` and\n  ``signed_deserialize``.\n\n- New interface: ``pyramid.interfaces.IRendererInfo``.  An object of this type\n  is passed to renderer factory constructors (see \"Backwards\n  Incompatibilities\").\n\n- New event type: ``pyramid.interfaces.IBeforeRender``.  An object of this type\n  is sent as an event before a renderer is invoked (but after the\n  application-level renderer globals factory added via\n  ``pyramid.configurator.configuration.set_renderer_globals_factory``, if any,\n  has injected its own keys).  Applications may now subscribe to the\n  ``IBeforeRender`` event type in order to introspect the and modify the set of\n  renderer globals before they are passed to a renderer.  The event object\n  iself has a dictionary-like interface that can be used for this purpose.  For\n  example::\n\n    from repoze.events import subscriber\n    from pyramid.interfaces import IRendererGlobalsEvent\n\n    @subscriber(IRendererGlobalsEvent)\n    def add_global(event):\n        event['mykey'] = 'foo'\n\n  If a subscriber attempts to add a key that already exist in the renderer\n  globals dictionary, a ``KeyError`` is raised.  This limitation is due to the\n  fact that subscribers cannot be ordered relative to each other.  The set of\n  keys added to the renderer globals dictionary by all subscribers and\n  app-level globals factories must be unique.\n\n- New class: ``pyramid.response.Response``.  This is a pure facade for\n  ``webob.Response`` (old code need not change to use this facade, it's\n  existence is mostly for vanity and documentation-generation purposes).\n\n- All preexisting paster templates (except ``zodb``) now use \"imperative\"\n  configuration (``starter``, ``routesalchemy``, ``alchemy``).\n\n- A new paster template named ``pyramid_starter_zcml`` exists, which uses\n  declarative configuration.\n\nDocumentation (delta from BFG 1.3)\n-----------------------------------\n\n- Added a ``pyramid.httpexceptions`` API documentation chapter.\n\n- Added a ``pyramid.session`` API documentation chapter.\n\n- Added a ``Session Objects`` narrative documentation chapter.\n\n- Added an API chapter for the ``pyramid.personality`` module.\n\n- Added an API chapter for the ``pyramid.response`` module.\n\n- All documentation which previously referred to ``webob.Response`` now uses\n  ``pyramid.response.Response`` instead.\n\n- The documentation has been overhauled to use imperative configuration,\n  moving declarative configuration (ZCML) explanations to a separate\n  narrative chapter ``declarative.rst``.\n\n- The ZODB Wiki tutorial was updated to take into account changes to the\n  ``pyramid_zodb`` paster template.\n\n- The SQL Wiki tutorial was updated to take into account changes to the\n  ``pyramid_routesalchemy`` paster template.\n\nBackwards Incompatibilities (with BFG 1.3)\n------------------------------------------\n\n- There is no longer an ``IDebugLogger`` registered as a named utility\n  with the name ``repoze.bfg.debug``.\n\n- The logger which used to have the name of ``repoze.bfg.debug`` now\n  has the name ``pyramid.debug``.\n\n- The deprecated API ``pyramid.testing.registerViewPermission``\n  has been removed.\n\n- The deprecated API named ``pyramid.testing.registerRoutesMapper``\n  has been removed.\n\n- The deprecated API named ``pyramid.request.get_request`` was removed.\n\n- The deprecated API named ``pyramid.security.Unauthorized`` was\n  removed.\n\n- The deprecated API named ``pyramid.view.view_execution_permitted``\n  was removed.\n\n- The deprecated API named ``pyramid.view.NotFound`` was removed.\n\n- The ``bfgshell`` paster command is now named ``pshell``.\n\n- The Venusian \"category\" for all built-in Venusian decorators\n  (e.g. ``subscriber`` and ``view_config``/``bfg_view``) is now\n  ``pyramid`` instead of ``bfg``.\n\n- ``pyramid.renderers.rendered_response`` function removed; use\n  ``render_pyramid.renderers.render_to_response`` instead.\n\n- Renderer factories now accept a *renderer info object* rather than an\n  absolute resource specification or an absolute path.  The object has the\n  following attributes: ``name`` (the ``renderer=`` value), ``package`` (the\n  'current package' when the renderer configuration statement was found),\n  ``type``: the renderer type, ``registry``: the current registry, and\n  ``settings``: the deployment settings dictionary.\n\n  Third-party ``repoze.bfg`` renderer implementations that must be ported to\n  Pyramid will need to account for this.\n\n  This change was made primarily to support more flexible Mako template\n  rendering.\n\n- The presence of the key ``repoze.bfg.message`` in the WSGI environment when\n  an exception occurs is now deprecated.  Instead, code which relies on this\n  environ value should use the ``exception`` attribute of the request\n  (e.g. ``request.exception[0]``) to retrieve the message.\n\n- The values ``bfg_localizer`` and ``bfg_locale_name`` kept on the request\n  during internationalization for caching purposes were never APIs.  These\n  however have changed to ``localizer`` and ``locale_name``, respectively.\n\n- The default ``cookie_name`` value of the ``authtktauthenticationpolicy`` ZCML\n  now defaults to ``auth_tkt`` (it used to default to ``repoze.bfg.auth_tkt``).\n\n- The default ``cookie_name`` value of the\n  ``pyramid.authentication.AuthTktAuthenticationPolicy`` constructor now\n  defaults to ``auth_tkt`` (it used to default to ``repoze.bfg.auth_tkt``).\n\n- The ``request_type`` argument to the ``view`` ZCML directive, the\n  ``pyramid.configuration.Configurator.add_view`` method, or the\n  ``pyramid.view.view_config`` decorator (nee ``bfg_view``) is no longer\n  permitted to be one of the strings ``GET``, ``HEAD``, ``PUT``, ``POST`` or\n  ``DELETE``, and now must always be an interface.  Accepting the\n  method-strings as ``request_type`` was a backwards compatibility strategy\n  servicing repoze.bfg 1.0 applications.  Use the ``request_method``\n  parameter instead to specify that a view a string request-method predicate.\n",
            "header": {
                "file": {
                    "path": "CHANGES.txt"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "dfa7bf7fc",
                "new_commit_hash": "be2bd2b5f",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/CHANGES.txt"
            },
            "plus_file": {
                "path": "b/CHANGES.txt"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 48,
                            "length": 6
                        },
                        "new_range": {
                            "start": 48,
                            "length": 12
                        },
                        "section": "Dependencies"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "Bug Fixes",
                                "type": "context"
                            },
                            {
                                "content": "---------",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "- When creating a Configurator from within a ``paster pshell`` session, you",
                                "type": "added"
                            },
                            {
                                "content": "  were required to pass a ``package`` argument although ``package`` is not",
                                "type": "added"
                            },
                            {
                                "content": "  actually required.  If you didn't pass ``package``, you would receive an",
                                "type": "added"
                            },
                            {
                                "content": "  error something like ``KeyError: '__name__'`` emanating from the",
                                "type": "added"
                            },
                            {
                                "content": "  ``pyramid.path.caller_module`` function.  This has now been fixed.",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "- The ``pyramid_routesalchemy`` paster template's unit tests failed",
                                "type": "context"
                            },
                            {
                                "content": "  (``AssertionError: 'SomeProject' != 'someproject'``).  This is fixed.",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import os\nimport pkg_resources\nimport sys\nimport imp\n\nignore_types = [ imp.C_EXTENSION, imp.C_BUILTIN ]\ninit_names = [ '__init__%s' % x[0] for x in imp.get_suffixes() if\n               x[0] and x[2] not in ignore_types ]\n\ndef caller_path(path, level=2):\n    if not os.path.isabs(path):\n        module = caller_module(level+1)\n        prefix = package_path(module)\n        path = os.path.join(prefix, path)\n    return path\n\ndef caller_module(level=2):\n    module_globals = sys._getframe(level).f_globals\n    module_name = module_globals['__name__']\n    module = sys.modules[module_name]\n    return module\n\ndef package_name(pkg_or_module):\n    \"\"\" If this function is passed a module, return the dotted Python\n    package name of the package in which the module lives.  If this\n    function is passed a package, return the dotted Python package\n    name of the package itself.\"\"\"\n    if pkg_or_module is None:\n        return '__main__'\n    pkg_filename = pkg_or_module.__file__\n    pkg_name = pkg_or_module.__name__\n    splitted = os.path.split(pkg_filename)\n    if splitted[-1] in init_names:\n        # it's a package\n        return pkg_name\n    return pkg_name.rsplit('.', 1)[0]\n\ndef package_of(pkg_or_module):\n    \"\"\" Return the package of a module or return the package itself \"\"\"\n    pkg_name = package_name(pkg_or_module)\n    __import__(pkg_name)\n    return sys.modules[pkg_name]\n\ndef caller_package(level=2, caller_module=caller_module):\n    # caller_module in arglist for tests\n    module = caller_module(level+1)\n    f = getattr(module, '__file__', '')\n    if (('__init__.py' in f) or ('__init__$py' in f)): # empty at >>>\n        # Module is a package\n        return module\n    # Go up one level to get package\n    package_name = module.__name__.rsplit('.', 1)[0]\n    return sys.modules[package_name]\n\ndef package_path(package):\n    # computing the abspath is actually kinda expensive so we memoize\n    # the result\n    prefix = getattr(package, '__abspath__', None)\n    if prefix is None:\n        prefix = pkg_resources.resource_filename(package.__name__, '')\n        # pkg_resources doesn't care whether we feed it a package\n        # name or a module name within the package, the result\n        # will be the same: a directory name to the package itself\n        try:\n            package.__abspath__ = prefix\n        except:\n            # this is only an optimization, ignore any error\n            pass\n    return prefix\n\n",
            "new_file_content": "import os\nimport pkg_resources\nimport sys\nimport imp\n\nignore_types = [ imp.C_EXTENSION, imp.C_BUILTIN ]\ninit_names = [ '__init__%s' % x[0] for x in imp.get_suffixes() if\n               x[0] and x[2] not in ignore_types ]\n\ndef caller_path(path, level=2):\n    if not os.path.isabs(path):\n        module = caller_module(level+1)\n        prefix = package_path(module)\n        path = os.path.join(prefix, path)\n    return path\n\ndef caller_module(level=2, sys=sys):\n    module_globals = sys._getframe(level).f_globals\n    module_name = module_globals.get('__name__') or '__main__'\n    module = sys.modules[module_name]\n    return module\n\ndef package_name(pkg_or_module):\n    \"\"\" If this function is passed a module, return the dotted Python\n    package name of the package in which the module lives.  If this\n    function is passed a package, return the dotted Python package\n    name of the package itself.\"\"\"\n    if pkg_or_module is None:\n        return '__main__'\n    pkg_filename = pkg_or_module.__file__\n    pkg_name = pkg_or_module.__name__\n    splitted = os.path.split(pkg_filename)\n    if splitted[-1] in init_names:\n        # it's a package\n        return pkg_name\n    return pkg_name.rsplit('.', 1)[0]\n\ndef package_of(pkg_or_module):\n    \"\"\" Return the package of a module or return the package itself \"\"\"\n    pkg_name = package_name(pkg_or_module)\n    __import__(pkg_name)\n    return sys.modules[pkg_name]\n\ndef caller_package(level=2, caller_module=caller_module):\n    # caller_module in arglist for tests\n    module = caller_module(level+1)\n    f = getattr(module, '__file__', '')\n    if (('__init__.py' in f) or ('__init__$py' in f)): # empty at >>>\n        # Module is a package\n        return module\n    # Go up one level to get package\n    package_name = module.__name__.rsplit('.', 1)[0]\n    return sys.modules[package_name]\n\ndef package_path(package):\n    # computing the abspath is actually kinda expensive so we memoize\n    # the result\n    prefix = getattr(package, '__abspath__', None)\n    if prefix is None:\n        prefix = pkg_resources.resource_filename(package.__name__, '')\n        # pkg_resources doesn't care whether we feed it a package\n        # name or a module name within the package, the result\n        # will be the same: a directory name to the package itself\n        try:\n            package.__abspath__ = prefix\n        except:\n            # this is only an optimization, ignore any error\n            pass\n    return prefix\n\n",
            "header": {
                "file": {
                    "path": "pyramid/path.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "10647c073",
                "new_commit_hash": "9c7be4c57",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/pyramid/path.py"
            },
            "plus_file": {
                "path": "b/pyramid/path.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 14,
                            "length": 9
                        },
                        "new_range": {
                            "start": 14,
                            "length": 9
                        },
                        "section": "def caller_path(path, level=2):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        path = os.path.join(prefix, path)",
                                "type": "context"
                            },
                            {
                                "content": "    return path",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def caller_module(level=2):",
                                "type": "deleted"
                            },
                            {
                                "content": "def caller_module(level=2, sys=sys):",
                                "type": "added"
                            },
                            {
                                "content": "    module_globals = sys._getframe(level).f_globals",
                                "type": "context"
                            },
                            {
                                "content": "    module_name = module_globals['__name__']",
                                "type": "deleted"
                            },
                            {
                                "content": "    module_name = module_globals.get('__name__') or '__main__'",
                                "type": "added"
                            },
                            {
                                "content": "    module = sys.modules[module_name]",
                                "type": "context"
                            },
                            {
                                "content": "    return module",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "pyramid/path.py",
                            "type": "function",
                            "name": "caller_module",
                            "content": "def caller_module(level=2):\n    module_globals = sys._getframe(level).f_globals\n    module_name = module_globals['__name__']\n    module = sys.modules[module_name]\n    return module",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 17,
                            "end_lineno": 21,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import unittest\n\nclass TestCallerPath(unittest.TestCase):\n    def tearDown(self):\n        from pyramid.tests import test_path\n        if hasattr(test_path, '__abspath__'):\n            del test_path.__abspath__\n\n    def _callFUT(self, path, level=2):\n        from pyramid.path import caller_path\n        return caller_path(path, level)\n\n    def test_isabs(self):\n        result = self._callFUT('/a/b/c')\n        self.assertEqual(result, '/a/b/c')\n\n    def test_pkgrelative(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n\n    def test_memoization_has_abspath(self):\n        import os\n        from pyramid.tests import test_path\n        test_path.__abspath__ = '/foo/bar'\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join('/foo/bar', 'a/b/c'))\n\n    def test_memoization_success(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        from pyramid.tests import test_path\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n        self.assertEqual(test_path.__abspath__, here)\n\nclass TestCallerModule(unittest.TestCase):\n    def _callFUT(self, level=2):\n        from pyramid.path import caller_module\n        return caller_module(level)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)\n\nclass TestCallerPackage(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_package\n        return caller_package(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid import tests\n        result = self._callFUT(1)\n        self.assertEqual(result, tests)\n\n    def test_it_level_2(self):\n        from pyramid import tests\n        result = self._callFUT(2)\n        self.assertEqual(result, tests)\n\n    def test_it_level_3(self):\n        import unittest\n        result = self._callFUT(3)\n        self.assertEqual(result, unittest)\n\n    def test_it_package(self):\n        import pyramid.tests\n        def dummy_caller_module(*arg):\n            return pyramid.tests\n        result = self._callFUT(1, caller_module=dummy_caller_module)\n        self.assertEqual(result, pyramid.tests)\n        \nclass TestPackagePath(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_path\n        return package_path(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, package.package_path)\n        \n    def test_it_module(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        result = self._callFUT(module)\n        self.assertEqual(result, module.package_path)\n\n    def test_memoization_success(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        self._callFUT(module)\n        self.assertEqual(module.__abspath__, module.package_path)\n        \n    def test_memoization_fail(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path, raise_exc=TypeError)\n        result = self._callFUT(module)\n        self.failIf(hasattr(module, '__abspath__'))\n        self.assertEqual(result, module.package_path)\n\nclass TestPackageOf(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_of\n        return package_of(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, tests)\n\n    def test_it_module(self):\n        import pyramid.tests.test_configuration\n        from pyramid import tests\n        package = DummyPackageOrModule(pyramid.tests.test_configuration)\n        result = self._callFUT(package)\n        self.assertEqual(result, tests)\n\nclass TestPackageName(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_name\n        return package_name(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, 'pyramid.tests')\n        \n    def test_it_module(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        result = self._callFUT(module)\n        self.assertEqual(result, 'pyramid.tests')\n\n    def test_it_None(self):\n        result = self._callFUT(None)\n        self.assertEqual(result, '__main__')\n    \nclass DummyPackageOrModule:\n    def __init__(self, real_package_or_module, raise_exc=None):\n        self.__dict__['raise_exc'] = raise_exc\n        self.__dict__['__name__'] = real_package_or_module.__name__\n        import os\n        self.__dict__['package_path'] = os.path.dirname(\n            os.path.abspath(real_package_or_module.__file__))\n        self.__dict__['__file__'] = real_package_or_module.__file__\n\n    def __setattr__(self, key, val):\n        if self.raise_exc is not None:\n            raise self.raise_exc\n        self.__dict__[key] = val\n        \n        \n    \n        \n\n    \n",
            "new_file_content": "import unittest\n\nclass TestCallerPath(unittest.TestCase):\n    def tearDown(self):\n        from pyramid.tests import test_path\n        if hasattr(test_path, '__abspath__'):\n            del test_path.__abspath__\n\n    def _callFUT(self, path, level=2):\n        from pyramid.path import caller_path\n        return caller_path(path, level)\n\n    def test_isabs(self):\n        result = self._callFUT('/a/b/c')\n        self.assertEqual(result, '/a/b/c')\n\n    def test_pkgrelative(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n\n    def test_memoization_has_abspath(self):\n        import os\n        from pyramid.tests import test_path\n        test_path.__abspath__ = '/foo/bar'\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join('/foo/bar', 'a/b/c'))\n\n    def test_memoization_success(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        from pyramid.tests import test_path\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n        self.assertEqual(test_path.__abspath__, here)\n\nclass TestCallerModule(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_module\n        return caller_module(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)\n\n    def test_it_no___name__(self):\n        class DummyFrame(object):\n            f_globals = {}\n        class DummySys(object):\n            def _getframe(self, level):\n                return DummyFrame()\n            modules = {'__main__':'main'}\n        dummy_sys = DummySys()\n        result = self._callFUT(3, sys=dummy_sys)\n        self.assertEqual(result, 'main')\n\n\nclass TestCallerPackage(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_package\n        return caller_package(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid import tests\n        result = self._callFUT(1)\n        self.assertEqual(result, tests)\n\n    def test_it_level_2(self):\n        from pyramid import tests\n        result = self._callFUT(2)\n        self.assertEqual(result, tests)\n\n    def test_it_level_3(self):\n        import unittest\n        result = self._callFUT(3)\n        self.assertEqual(result, unittest)\n\n    def test_it_package(self):\n        import pyramid.tests\n        def dummy_caller_module(*arg):\n            return pyramid.tests\n        result = self._callFUT(1, caller_module=dummy_caller_module)\n        self.assertEqual(result, pyramid.tests)\n        \nclass TestPackagePath(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_path\n        return package_path(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, package.package_path)\n        \n    def test_it_module(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        result = self._callFUT(module)\n        self.assertEqual(result, module.package_path)\n\n    def test_memoization_success(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        self._callFUT(module)\n        self.assertEqual(module.__abspath__, module.package_path)\n        \n    def test_memoization_fail(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path, raise_exc=TypeError)\n        result = self._callFUT(module)\n        self.failIf(hasattr(module, '__abspath__'))\n        self.assertEqual(result, module.package_path)\n\nclass TestPackageOf(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_of\n        return package_of(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, tests)\n\n    def test_it_module(self):\n        import pyramid.tests.test_configuration\n        from pyramid import tests\n        package = DummyPackageOrModule(pyramid.tests.test_configuration)\n        result = self._callFUT(package)\n        self.assertEqual(result, tests)\n\nclass TestPackageName(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_name\n        return package_name(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, 'pyramid.tests')\n        \n    def test_it_module(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        result = self._callFUT(module)\n        self.assertEqual(result, 'pyramid.tests')\n\n    def test_it_None(self):\n        result = self._callFUT(None)\n        self.assertEqual(result, '__main__')\n    \nclass DummyPackageOrModule:\n    def __init__(self, real_package_or_module, raise_exc=None):\n        self.__dict__['raise_exc'] = raise_exc\n        self.__dict__['__name__'] = real_package_or_module.__name__\n        import os\n        self.__dict__['package_path'] = os.path.dirname(\n            os.path.abspath(real_package_or_module.__file__))\n        self.__dict__['__file__'] = real_package_or_module.__file__\n\n    def __setattr__(self, key, val):\n        if self.raise_exc is not None:\n            raise self.raise_exc\n        self.__dict__[key] = val\n        \n        \n    \n        \n\n    \n",
            "header": {
                "file": {
                    "path": "pyramid/tests/test_path.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "c097615af",
                "new_commit_hash": "5619aafa1",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/pyramid/tests/test_path.py"
            },
            "plus_file": {
                "path": "b/pyramid/tests/test_path.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 36,
                            "length": 9
                        },
                        "new_range": {
                            "start": 36,
                            "length": 9
                        },
                        "section": "class TestCallerPath(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.assertEqual(test_path.__abspath__, here)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "class TestCallerModule(unittest.TestCase):",
                                "type": "context"
                            },
                            {
                                "content": "    def _callFUT(self, level=2):",
                                "type": "deleted"
                            },
                            {
                                "content": "    def _callFUT(self, *arg, **kw):",
                                "type": "added"
                            },
                            {
                                "content": "        from pyramid.path import caller_module",
                                "type": "context"
                            },
                            {
                                "content": "        return caller_module(level)",
                                "type": "deleted"
                            },
                            {
                                "content": "        return caller_module(*arg, **kw)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_it_level_1(self):",
                                "type": "context"
                            },
                            {
                                "content": "        from pyramid.tests import test_path",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "pyramid/tests/test_path.py",
                            "type": "method",
                            "name": "TestCallerModule._callFUT",
                            "content": "class TestCallerModule(unittest.TestCase):\n    def _callFUT(self, level=2):\n        from pyramid.path import caller_module\n        return caller_module(level)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 39,
                            "end_lineno": 41,
                            "parent": {
                                "file_name": "pyramid/tests/test_path.py",
                                "type": "class",
                                "name": "TestCallerModule",
                                "content": "class TestCallerModule(unittest.TestCase):\n    def _callFUT(self, level=2):\n        from pyramid.path import caller_module\n        return caller_module(level)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 38,
                                "end_lineno": 56,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "pyramid/tests/test_path.py",
                            "type": "class",
                            "name": "TestCallerModule",
                            "content": "class TestCallerModule(unittest.TestCase):\n    def _callFUT(self, level=2):\n        from pyramid.path import caller_module\n        return caller_module(level)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 38,
                            "end_lineno": 56,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 55,
                            "length": 6
                        },
                        "new_range": {
                            "start": 55,
                            "length": 18
                        },
                        "section": "class TestCallerModule(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        result = self._callFUT(3)",
                                "type": "context"
                            },
                            {
                                "content": "        self.failIfEqual(result, test_path)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_it_no___name__(self):",
                                "type": "added"
                            },
                            {
                                "content": "        class DummyFrame(object):",
                                "type": "added"
                            },
                            {
                                "content": "            f_globals = {}",
                                "type": "added"
                            },
                            {
                                "content": "        class DummySys(object):",
                                "type": "added"
                            },
                            {
                                "content": "            def _getframe(self, level):",
                                "type": "added"
                            },
                            {
                                "content": "                return DummyFrame()",
                                "type": "added"
                            },
                            {
                                "content": "            modules = {'__main__':'main'}",
                                "type": "added"
                            },
                            {
                                "content": "        dummy_sys = DummySys()",
                                "type": "added"
                            },
                            {
                                "content": "        result = self._callFUT(3, sys=dummy_sys)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(result, 'main')",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "class TestCallerPackage(unittest.TestCase):",
                                "type": "context"
                            },
                            {
                                "content": "    def _callFUT(self, *arg, **kw):",
                                "type": "context"
                            },
                            {
                                "content": "        from pyramid.path import caller_package",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "pyramid/tests/test_path.py",
                            "type": "class",
                            "name": "TestCallerModule",
                            "content": "class TestCallerModule(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_module\n        return caller_module(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)\n\n    def test_it_no___name__(self):\n        class DummyFrame(object):\n            f_globals = {}\n        class DummySys(object):\n            def _getframe(self, level):\n                return DummyFrame()\n            modules = {'__main__':'main'}\n        dummy_sys = DummySys()\n        result = self._callFUT(3, sys=dummy_sys)\n        self.assertEqual(result, 'main')",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 38,
                            "end_lineno": 67,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "pyramid/tests/test_path.py",
                            "type": "method",
                            "name": "TestCallerModule.test_it_no___name__",
                            "content": "class TestCallerModule(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_module\n        return caller_module(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)\n\n    def test_it_no___name__(self):\n        class DummyFrame(object):\n            f_globals = {}\n        class DummySys(object):\n            def _getframe(self, level):\n                return DummyFrame()\n            modules = {'__main__':'main'}\n        dummy_sys = DummySys()\n        result = self._callFUT(3, sys=dummy_sys)\n        self.assertEqual(result, 'main')",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 58,
                            "end_lineno": 67,
                            "parent": {
                                "file_name": "pyramid/tests/test_path.py",
                                "type": "class",
                                "name": "TestCallerModule",
                                "content": "class TestCallerModule(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_module\n        return caller_module(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)\n\n    def test_it_no___name__(self):\n        class DummyFrame(object):\n            f_globals = {}\n        class DummySys(object):\n            def _getframe(self, level):\n                return DummyFrame()\n            modules = {'__main__':'main'}\n        dummy_sys = DummySys()\n        result = self._callFUT(3, sys=dummy_sys)\n        self.assertEqual(result, 'main')",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 38,
                                "end_lineno": 67,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "a56564945ae07da87e5ccbca9c137095c250ced3^",
    "new_commit_hash": "a56564945ae07da87e5ccbca9c137095c250ced3",
    "commit_message": "- When creating a Configurator from within a ``paster pshell`` session, you\n  were required to pass a ``package`` argument although ``package`` is not\n  actually required.  If you didn't pass ``package``, you would receive an\n  error something like ``KeyError: '__name__'`` emanating from the\n  ``pyramid.path.caller_module`` function.  This has now been fixed.",
    "commit_date": "2010-12-13T23:28:59-05:00",
    "metadata": {}
}
{
    "repo_name": "pyramid",
    "new_commit_hash": "a56564945ae07da87e5ccbca9c137095c250ced3",
    "test_file_codes": [
        "import unittest\n\nclass TestCallerPath(unittest.TestCase):\n    def tearDown(self):\n        from pyramid.tests import test_path\n        if hasattr(test_path, '__abspath__'):\n            del test_path.__abspath__\n\n    def _callFUT(self, path, level=2):\n        from pyramid.path import caller_path\n        return caller_path(path, level)\n\n    def test_isabs(self):\n        result = self._callFUT('/a/b/c')\n        self.assertEqual(result, '/a/b/c')\n\n    def test_pkgrelative(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n\n    def test_memoization_has_abspath(self):\n        import os\n        from pyramid.tests import test_path\n        test_path.__abspath__ = '/foo/bar'\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join('/foo/bar', 'a/b/c'))\n\n    def test_memoization_success(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        from pyramid.tests import test_path\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n        self.assertEqual(test_path.__abspath__, here)\n\nclass TestCallerModule(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_module\n        return caller_module(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n        self.assertEqual(result, test_path)\n\n    def test_it_level_3(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(3)\n        self.failIfEqual(result, test_path)\n\n    def test_it_no___name__(self):\n        class DummyFrame(object):\n            f_globals = {}\n        class DummySys(object):\n            def _getframe(self, level):\n                return DummyFrame()\n            modules = {'__main__':'main'}\n        dummy_sys = DummySys()\n        result = self._callFUT(3, sys=dummy_sys)\n        self.assertEqual(result, 'main')\n\n\nclass TestCallerPackage(unittest.TestCase):\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_package\n        return caller_package(*arg, **kw)\n\n    def test_it_level_1(self):\n        from pyramid import tests\n        result = self._callFUT(1)\n        self.assertEqual(result, tests)\n\n    def test_it_level_2(self):\n        from pyramid import tests\n        result = self._callFUT(2)\n        self.assertEqual(result, tests)\n\n    def test_it_level_3(self):\n        import unittest\n        result = self._callFUT(3)\n        self.assertEqual(result, unittest)\n\n    def test_it_package(self):\n        import pyramid.tests\n        def dummy_caller_module(*arg):\n            return pyramid.tests\n        result = self._callFUT(1, caller_module=dummy_caller_module)\n        self.assertEqual(result, pyramid.tests)\n        \nclass TestPackagePath(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_path\n        return package_path(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, package.package_path)\n        \n    def test_it_module(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        result = self._callFUT(module)\n        self.assertEqual(result, module.package_path)\n\n    def test_memoization_success(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        self._callFUT(module)\n        self.assertEqual(module.__abspath__, module.package_path)\n        \n    def test_memoization_fail(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path, raise_exc=TypeError)\n        result = self._callFUT(module)\n        self.failIf(hasattr(module, '__abspath__'))\n        self.assertEqual(result, module.package_path)\n\nclass TestPackageOf(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_of\n        return package_of(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, tests)\n\n    def test_it_module(self):\n        import pyramid.tests.test_configuration\n        from pyramid import tests\n        package = DummyPackageOrModule(pyramid.tests.test_configuration)\n        result = self._callFUT(package)\n        self.assertEqual(result, tests)\n\nclass TestPackageName(unittest.TestCase):\n    def _callFUT(self, package):\n        from pyramid.path import package_name\n        return package_name(package)\n\n    def test_it_package(self):\n        from pyramid import tests\n        package = DummyPackageOrModule(tests)\n        result = self._callFUT(package)\n        self.assertEqual(result, 'pyramid.tests')\n        \n    def test_it_module(self):\n        from pyramid.tests import test_path\n        module = DummyPackageOrModule(test_path)\n        result = self._callFUT(module)\n        self.assertEqual(result, 'pyramid.tests')\n\n    def test_it_None(self):\n        result = self._callFUT(None)\n        self.assertEqual(result, '__main__')\n    \nclass DummyPackageOrModule:\n    def __init__(self, real_package_or_module, raise_exc=None):\n        self.__dict__['raise_exc'] = raise_exc\n        self.__dict__['__name__'] = real_package_or_module.__name__\n        import os\n        self.__dict__['package_path'] = os.path.dirname(\n            os.path.abspath(real_package_or_module.__file__))\n        self.__dict__['__file__'] = real_package_or_module.__file__\n\n    def __setattr__(self, key, val):\n        if self.raise_exc is not None:\n            raise self.raise_exc\n        self.__dict__[key] = val\n        \n        \n    \n        \n\n    \n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "",
    "setup_res_stderr": "Using CPython 3.8.20\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 23 packages in 807ms\nPrepared 1 package in 675ms\nInstalled 23 packages in 15ms\n + chameleon==4.4.4\n + importlib-metadata==8.5.0\n + importlib-resources==6.4.5\n + mako==1.3.8\n + markupsafe==2.1.5\n + paste==3.10.1\n + pastedeploy==3.1.0\n + pastescript==3.6.0\n + pyramid==0.0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/pyramid_a56564945ae07da87e5ccbca9c137095c250ced3)\n + repoze-lru==0.7\n + setuptools==75.3.0\n + translationstring==1.4\n + venusian==3.1.1\n + webob==1.8.9\n + zipp==3.20.2\n + zope-component==6.0\n + zope-configuration==6.0\n + zope-deprecation==5.0\n + zope-event==5.0\n + zope-hookable==7.0\n + zope-i18nmessageid==7.0\n + zope-interface==7.2\n + zope-schema==7.0.1\nAudited 1 package in 2ms\nResolved 16 packages in 6ms\nInstalled 16 packages in 9ms\n + cachetools==5.5.0\n + chardet==5.2.0\n + colorama==0.4.6\n + distlib==0.3.9\n + exceptiongroup==1.2.2\n + filelock==3.16.1\n + iniconfig==2.0.0\n + packaging==24.2\n + platformdirs==4.3.6\n + pluggy==1.5.0\n + pyproject-api==1.8.0\n + pytest==8.3.4\n + tomli==2.2.1\n + tox==4.23.2\n + typing-extensions==4.12.2\n + virtualenv==20.29.0\n",
    "new_commit_res_code": 1,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.8.20, pytest-8.3.4, pluggy-1.5.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/pyramid_a56564945ae07da87e5ccbca9c137095c250ced3\ncollected 21 items\n\nr2e_tests/test_1.py .FF.FF..FF...........                                [100%]\n\n=================================== FAILURES ===================================\n_________________ TestCallerPath.test_memoization_has_abspath __________________\n\nself = <r2e_tests.test_1.TestCallerPath testMethod=test_memoization_has_abspath>\n\n    def test_memoization_has_abspath(self):\n        import os\n        from pyramid.tests import test_path\n        test_path.__abspath__ = '/foo/bar'\n        result = self._callFUT('a/b/c')\n>       self.assertEqual(result, os.path.join('/foo/bar', 'a/b/c'))\nE       AssertionError: '/home/gcpuser/buckets/local_repoeval_bucke[68 chars]/b/c' != '/foo/bar/a/b/c'\nE       - /home/gcpuser/buckets/local_repoeval_bucket/repos/pyramid_a56564945ae07da87e5ccbca9c137095c250ced3/r2e_tests/a/b/c\nE       + /foo/bar/a/b/c\n\nr2e_tests/test_1.py:28: AssertionError\n___________________ TestCallerPath.test_memoization_success ____________________\n\nself = <r2e_tests.test_1.TestCallerPath testMethod=test_memoization_success>\n\n    def test_memoization_success(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        from pyramid.tests import test_path\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n>       self.assertEqual(test_path.__abspath__, here)\nE       AttributeError: module 'pyramid.tests.test_path' has no attribute '__abspath__'\n\nr2e_tests/test_1.py:36: AttributeError\n_______________________ TestCallerModule.test_it_level_1 _______________________\n\nself = <r2e_tests.test_1.TestCallerModule testMethod=test_it_level_1>\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n>       self.assertEqual(result, test_path)\nE       AssertionError: <module 'r2e_tests.test_1' from '/home/gcpuser/buc[98 chars].py'> != <module 'pyramid.tests.test_path' from '/home/gcpu[112 chars].py'>\n\nr2e_tests/test_1.py:46: AssertionError\n_______________________ TestCallerModule.test_it_level_2 _______________________\n\nself = <r2e_tests.test_1.TestCallerModule testMethod=test_it_level_2>\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n>       self.assertEqual(result, test_path)\nE       AssertionError: <module 'r2e_tests.test_1' from '/home/gcpuser/buc[98 chars].py'> != <module 'pyramid.tests.test_path' from '/home/gcpu[112 chars].py'>\n\nr2e_tests/test_1.py:51: AssertionError\n______________________ TestCallerPackage.test_it_level_1 _______________________\n\nself = <r2e_tests.test_1.TestCallerPackage testMethod=test_it_level_1>\n\n    def test_it_level_1(self):\n        from pyramid import tests\n        result = self._callFUT(1)\n>       self.assertEqual(result, tests)\nE       AssertionError: <module 'r2e_tests' from '/home/gcpuser/buckets/lo[93 chars].py'> != <module 'pyramid.tests' from '/home/gcpuser/bucket[101 chars].py'>\n\nr2e_tests/test_1.py:78: AssertionError\n______________________ TestCallerPackage.test_it_level_2 _______________________\n\nself = <r2e_tests.test_1.TestCallerPackage testMethod=test_it_level_2>\n\n    def test_it_level_2(self):\n        from pyramid import tests\n        result = self._callFUT(2)\n>       self.assertEqual(result, tests)\nE       AssertionError: <module 'r2e_tests' from '/home/gcpuser/buckets/lo[93 chars].py'> != <module 'pyramid.tests' from '/home/gcpuser/bucket[101 chars].py'>\n\nr2e_tests/test_1.py:83: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestCallerPath::test_isabs\nPASSED r2e_tests/test_1.py::TestCallerPath::test_pkgrelative\nPASSED r2e_tests/test_1.py::TestCallerModule::test_it_level_3\nPASSED r2e_tests/test_1.py::TestCallerModule::test_it_no___name__\nPASSED r2e_tests/test_1.py::TestCallerPackage::test_it_level_3\nPASSED r2e_tests/test_1.py::TestCallerPackage::test_it_package\nPASSED r2e_tests/test_1.py::TestPackagePath::test_it_module\nPASSED r2e_tests/test_1.py::TestPackagePath::test_it_package\nPASSED r2e_tests/test_1.py::TestPackagePath::test_memoization_fail\nPASSED r2e_tests/test_1.py::TestPackagePath::test_memoization_success\nPASSED r2e_tests/test_1.py::TestPackageOf::test_it_module\nPASSED r2e_tests/test_1.py::TestPackageOf::test_it_package\nPASSED r2e_tests/test_1.py::TestPackageName::test_it_None\nPASSED r2e_tests/test_1.py::TestPackageName::test_it_module\nPASSED r2e_tests/test_1.py::TestPackageName::test_it_package\nFAILED r2e_tests/test_1.py::TestCallerPath::test_memoization_has_abspath - As...\nFAILED r2e_tests/test_1.py::TestCallerPath::test_memoization_success - Attrib...\nFAILED r2e_tests/test_1.py::TestCallerModule::test_it_level_1 - AssertionErro...\nFAILED r2e_tests/test_1.py::TestCallerModule::test_it_level_2 - AssertionErro...\nFAILED r2e_tests/test_1.py::TestCallerPackage::test_it_level_1 - AssertionErr...\nFAILED r2e_tests/test_1.py::TestCallerPackage::test_it_level_2 - AssertionErr...\n========================= 6 failed, 15 passed in 0.27s =========================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.8.20, pytest-8.3.4, pluggy-1.5.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/pyramid_a56564945ae07da87e5ccbca9c137095c250ced3\ncollected 21 items\n\nr2e_tests/test_1.py .FF.FF.FFF...........                                [100%]\n\n=================================== FAILURES ===================================\n_________________ TestCallerPath.test_memoization_has_abspath __________________\n\nself = <r2e_tests.test_1.TestCallerPath testMethod=test_memoization_has_abspath>\n\n    def test_memoization_has_abspath(self):\n        import os\n        from pyramid.tests import test_path\n        test_path.__abspath__ = '/foo/bar'\n        result = self._callFUT('a/b/c')\n>       self.assertEqual(result, os.path.join('/foo/bar', 'a/b/c'))\nE       AssertionError: '/home/gcpuser/buckets/local_repoeval_bucke[68 chars]/b/c' != '/foo/bar/a/b/c'\nE       - /home/gcpuser/buckets/local_repoeval_bucket/repos/pyramid_a56564945ae07da87e5ccbca9c137095c250ced3/r2e_tests/a/b/c\nE       + /foo/bar/a/b/c\n\nr2e_tests/test_1.py:28: AssertionError\n___________________ TestCallerPath.test_memoization_success ____________________\n\nself = <r2e_tests.test_1.TestCallerPath testMethod=test_memoization_success>\n\n    def test_memoization_success(self):\n        import os\n        here = os.path.abspath(os.path.dirname(__file__))\n        from pyramid.tests import test_path\n        result = self._callFUT('a/b/c')\n        self.assertEqual(result, os.path.join(here, 'a/b/c'))\n>       self.assertEqual(test_path.__abspath__, here)\nE       AttributeError: module 'pyramid.tests.test_path' has no attribute '__abspath__'\n\nr2e_tests/test_1.py:36: AttributeError\n_______________________ TestCallerModule.test_it_level_1 _______________________\n\nself = <r2e_tests.test_1.TestCallerModule testMethod=test_it_level_1>\n\n    def test_it_level_1(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(1)\n>       self.assertEqual(result, test_path)\nE       AssertionError: <module 'r2e_tests.test_1' from '/home/gcpuser/buc[98 chars].py'> != <module 'pyramid.tests.test_path' from '/home/gcpu[112 chars].py'>\n\nr2e_tests/test_1.py:46: AssertionError\n_______________________ TestCallerModule.test_it_level_2 _______________________\n\nself = <r2e_tests.test_1.TestCallerModule testMethod=test_it_level_2>\n\n    def test_it_level_2(self):\n        from pyramid.tests import test_path\n        result = self._callFUT(2)\n>       self.assertEqual(result, test_path)\nE       AssertionError: <module 'r2e_tests.test_1' from '/home/gcpuser/buc[98 chars].py'> != <module 'pyramid.tests.test_path' from '/home/gcpu[112 chars].py'>\n\nr2e_tests/test_1.py:51: AssertionError\n_____________________ TestCallerModule.test_it_no___name__ _____________________\n\nself = <r2e_tests.test_1.TestCallerModule testMethod=test_it_no___name__>\n\n    def test_it_no___name__(self):\n        class DummyFrame(object):\n            f_globals = {}\n        class DummySys(object):\n            def _getframe(self, level):\n                return DummyFrame()\n            modules = {'__main__':'main'}\n        dummy_sys = DummySys()\n>       result = self._callFUT(3, sys=dummy_sys)\n\nr2e_tests/test_1.py:66: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <r2e_tests.test_1.TestCallerModule testMethod=test_it_no___name__>\narg = (3,)\nkw = {'sys': <r2e_tests.test_1.TestCallerModule.test_it_no___name__.<locals>.DummySys object at 0x7cca126c8100>}\ncaller_module = <function caller_module at 0x7cca12717ee0>\n\n    def _callFUT(self, *arg, **kw):\n        from pyramid.path import caller_module\n>       return caller_module(*arg, **kw)\nE       TypeError: caller_module() got an unexpected keyword argument 'sys'\n\nr2e_tests/test_1.py:41: TypeError\n______________________ TestCallerPackage.test_it_level_1 _______________________\n\nself = <r2e_tests.test_1.TestCallerPackage testMethod=test_it_level_1>\n\n    def test_it_level_1(self):\n        from pyramid import tests\n        result = self._callFUT(1)\n>       self.assertEqual(result, tests)\nE       AssertionError: <module 'r2e_tests' from '/home/gcpuser/buckets/lo[93 chars].py'> != <module 'pyramid.tests' from '/home/gcpuser/bucket[101 chars].py'>\n\nr2e_tests/test_1.py:78: AssertionError\n______________________ TestCallerPackage.test_it_level_2 _______________________\n\nself = <r2e_tests.test_1.TestCallerPackage testMethod=test_it_level_2>\n\n    def test_it_level_2(self):\n        from pyramid import tests\n        result = self._callFUT(2)\n>       self.assertEqual(result, tests)\nE       AssertionError: <module 'r2e_tests' from '/home/gcpuser/buckets/lo[93 chars].py'> != <module 'pyramid.tests' from '/home/gcpuser/bucket[101 chars].py'>\n\nr2e_tests/test_1.py:83: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestCallerPath::test_isabs\nPASSED r2e_tests/test_1.py::TestCallerPath::test_pkgrelative\nPASSED r2e_tests/test_1.py::TestCallerModule::test_it_level_3\nPASSED r2e_tests/test_1.py::TestCallerPackage::test_it_level_3\nPASSED r2e_tests/test_1.py::TestCallerPackage::test_it_package\nPASSED r2e_tests/test_1.py::TestPackagePath::test_it_module\nPASSED r2e_tests/test_1.py::TestPackagePath::test_it_package\nPASSED r2e_tests/test_1.py::TestPackagePath::test_memoization_fail\nPASSED r2e_tests/test_1.py::TestPackagePath::test_memoization_success\nPASSED r2e_tests/test_1.py::TestPackageOf::test_it_module\nPASSED r2e_tests/test_1.py::TestPackageOf::test_it_package\nPASSED r2e_tests/test_1.py::TestPackageName::test_it_None\nPASSED r2e_tests/test_1.py::TestPackageName::test_it_module\nPASSED r2e_tests/test_1.py::TestPackageName::test_it_package\nFAILED r2e_tests/test_1.py::TestCallerPath::test_memoization_has_abspath - As...\nFAILED r2e_tests/test_1.py::TestCallerPath::test_memoization_success - Attrib...\nFAILED r2e_tests/test_1.py::TestCallerModule::test_it_level_1 - AssertionErro...\nFAILED r2e_tests/test_1.py::TestCallerModule::test_it_level_2 - AssertionErro...\nFAILED r2e_tests/test_1.py::TestCallerModule::test_it_no___name__ - TypeError...\nFAILED r2e_tests/test_1.py::TestCallerPackage::test_it_level_1 - AssertionErr...\nFAILED r2e_tests/test_1.py::TestCallerPackage::test_it_level_2 - AssertionErr...\n========================= 7 failed, 14 passed in 0.17s =========================\n",
    "old_commit_res_stderr": ""
}
CHANGES.txt pyramid/path.py pyramid/tests/test_path.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]

**Title:** Creating Configurator Without `package` in `paster pshell` Causes KeyError

**Description:**
When initializing a `Configurator` within a `paster pshell` session without providing the `package` argument, a `KeyError` is raised. This error originates from the `pyramid.path.caller_module` function, which expects the `__name__` key to be present in the module globals. However, in this context, `__name__` might not be defined, leading to the unexpected error.

**Example Buggy Code:**
```python
from pyramid.config import Configurator

# Attempting to create a Configurator without the 'package' argument
configurator = Configurator()
```

**Expected Behavior:**
The `Configurator` should initialize successfully without requiring the `package` argument when used within a `paster pshell` session.

**Actual Behavior:**
A `KeyError: '__name__'` is raised, preventing the Configurator from being created properly.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### pyramid/path.py
import os
import pkg_resources
import sys
import imp

ignore_types = [ imp.C_EXTENSION, imp.C_BUILTIN ]
init_names = [ '__init__%s' % x[0] for x in imp.get_suffixes() if
               x[0] and x[2] not in ignore_types ]

def caller_path(path, level=2):
    if not os.path.isabs(path):
        module = caller_module(level+1)
        prefix = package_path(module)
        path = os.path.join(prefix, path)
    return path

def caller_module(level=2):
    module_globals = sys._getframe(level).f_globals
    module_name = module_globals['__name__']
    module = sys.modules[module_name]
    return module

def package_name(pkg_or_module):
    """ If this function is passed a module, return the dotted Python
    package name of the package in which the module lives.  If this
    function is passed a package, return the dotted Python package
    name of the package itself."""
    if pkg_or_module is None:
        return '__main__'
    pkg_filename = pkg_or_module.__file__
    pkg_name = pkg_or_module.__name__
    splitted = os.path.split(pkg_filename)
    if splitted[-1] in init_names:
        # it's a package
        return pkg_name
    return pkg_name.rsplit('.', 1)[0]

def package_of(pkg_or_module):
    """ Return the package of a module or return the package itself """
    pkg_name = package_name(pkg_or_module)
    __import__(pkg_name)
    return sys.modules[pkg_name]

def caller_package(level=2, caller_module=caller_module):
    # caller_module in arglist for tests
    module = caller_module(level+1)
    f = getattr(module, '__file__', '')
    if (('__init__.py' in f) or ('__init__$py' in f)): # empty at >>>
        # Module is a package
        return module
    # Go up one level to get package
    package_name = module.__name__.rsplit('.', 1)[0]
    return sys.modules[package_name]

def package_path(package):
    # computing the abspath is actually kinda expensive so we memoize
    # the result
    prefix = getattr(package, '__abspath__', None)
    if prefix is None:
        prefix = pkg_resources.resource_filename(package.__name__, '')
        # pkg_resources doesn't care whether we feed it a package
        # name or a module name within the package, the result
        # will be the same: a directory name to the package itself
        try:
            package.__abspath__ = prefix
        except:
            # this is only an optimization, ignore any error
            pass
    return prefix


```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]

**Title:** Creating Configurator Without `package` in `paster pshell` Causes KeyError

**Description:**
When initializing a `Configurator` within a `paster pshell` session without providing the `package` argument, a `KeyError` is raised. This error originates from the `pyramid.path.caller_module` function, which expects the `__name__` key to be present in the module globals. However, in this context, `__name__` might not be defined, leading to the unexpected error.

**Example Buggy Code:**
```python
from pyramid.config import Configurator

# Attempting to create a Configurator without the 'package' argument
configurator = Configurator()
```

**Expected Behavior:**
The `Configurator` should initialize successfully without requiring the `package` argument when used within a `paster pshell` session.

**Actual Behavior:**
A `KeyError: '__name__'` is raised, preventing the Configurator from being created properly.

[/ISSUE]
{
    "TestCallerPath.test_isabs": "PASSED",
    "TestCallerPath.test_pkgrelative": "PASSED",
    "TestCallerModule.test_it_level_3": "PASSED",
    "TestCallerModule.test_it_no___name__": "PASSED",
    "TestCallerPackage.test_it_level_3": "PASSED",
    "TestCallerPackage.test_it_package": "PASSED",
    "TestPackagePath.test_it_module": "PASSED",
    "TestPackagePath.test_it_package": "PASSED",
    "TestPackagePath.test_memoization_fail": "PASSED",
    "TestPackagePath.test_memoization_success": "PASSED",
    "TestPackageOf.test_it_module": "PASSED",
    "TestPackageOf.test_it_package": "PASSED",
    "TestPackageName.test_it_None": "PASSED",
    "TestPackageName.test_it_module": "PASSED",
    "TestPackageName.test_it_package": "PASSED",
    "TestCallerPath.test_memoization_has_abspath": "FAILED",
    "TestCallerPath.test_memoization_success": "FAILED",
    "TestCallerModule.test_it_level_1": "FAILED",
    "TestCallerModule.test_it_level_2": "FAILED",
    "TestCallerPackage.test_it_level_1": "FAILED",
    "TestCallerPackage.test_it_level_2": "FAILED"
}
diff --git a/pyramid/path.py b/pyramid/path.py
index 10647c073..9c7be4c57 100644
--- a/pyramid/path.py
+++ b/pyramid/path.py
@@ -14,9 +14,9 @@ def caller_path(path, level=2):
         path = os.path.join(prefix, path)
     return path
 
-def caller_module(level=2):
+def caller_module(level=2, sys=sys):
     module_globals = sys._getframe(level).f_globals
-    module_name = module_globals['__name__']
+    module_name = module_globals.get('__name__') or '__main__'
     module = sys.modules[module_name]
     return module
 

{"pyramid/path.py": "import os\nimport pkg_resources\nimport sys\nimport imp\n\nignore_types = [ imp.C_EXTENSION, imp.C_BUILTIN ]\ninit_names = [ '__init__%s' % x[0] for x in imp.get_suffixes() if\n               x[0] and x[2] not in ignore_types ]\n\ndef caller_path(path, level=2):\n    if not os.path.isabs(path):\n        module = caller_module(level+1)\n        prefix = package_path(module)\n        path = os.path.join(prefix, path)\n    return path\n\ndef caller_module(level=2):\n    module_globals = sys._getframe(level).f_globals\n    module_name = module_globals['__name__']\n    module = sys.modules[module_name]\n    return module\n\ndef package_name(pkg_or_module):\n    \"\"\" If this function is passed a module, return the dotted Python\n    package name of the package in which the module lives.  If this\n    function is passed a package, return the dotted Python package\n    name of the package itself.\"\"\"\n    if pkg_or_module is None:\n        return '__main__'\n    pkg_filename = pkg_or_module.__file__\n    pkg_name = pkg_or_module.__name__\n    splitted = os.path.split(pkg_filename)\n    if splitted[-1] in init_names:\n        # it's a package\n        return pkg_name\n    return pkg_name.rsplit('.', 1)[0]\n\ndef package_of(pkg_or_module):\n    \"\"\" Return the package of a module or return the package itself \"\"\"\n    pkg_name = package_name(pkg_or_module)\n    __import__(pkg_name)\n    return sys.modules[pkg_name]\n\ndef caller_package(level=2, caller_module=caller_module):\n    # caller_module in arglist for tests\n    module = caller_module(level+1)\n    f = getattr(module, '__file__', '')\n    if (('__init__.py' in f) or ('__init__$py' in f)): # empty at >>>\n        # Module is a package\n        return module\n    # Go up one level to get package\n    package_name = module.__name__.rsplit('.', 1)[0]\n    return sys.modules[package_name]\n\ndef package_path(package):\n    # computing the abspath is actually kinda expensive so we memoize\n    # the result\n    prefix = getattr(package, '__abspath__', None)\n    if prefix is None:\n        prefix = pkg_resources.resource_filename(package.__name__, '')\n        # pkg_resources doesn't care whether we feed it a package\n        # name or a module name within the package, the result\n        # will be the same: a directory name to the package itself\n        try:\n            package.__abspath__ = prefix\n        except:\n            # this is only an optimization, ignore any error\n            pass\n    return prefix\n\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]

**Title:** Creating Configurator Without `package` in `paster pshell` Causes KeyError

**Description:**
When initializing a `Configurator` within a `paster pshell` session without providing the `package` argument, a `KeyError` is raised. This error originates from the `pyramid.path.caller_module` function, which expects the `__name__` key to be present in the module globals. However, in this context, `__name__` might not be defined, leading to the unexpected error.

**Example Buggy Code:**
```python
from pyramid.config import Configurator

# Attempting to create a Configurator without the 'package' argument
configurator = Configurator()
```

**Expected Behavior:**
The `Configurator` should initialize successfully without requiring the `package` argument when used within a `paster pshell` session.

**Actual Behavior:**
A `KeyError: '__name__'` is raised, preventing the Configurator from being created properly.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### pyramid/path.py
import os
import pkg_resources
import sys
import imp

ignore_types = [ imp.C_EXTENSION, imp.C_BUILTIN ]
init_names = [ '__init__%s' % x[0] for x in imp.get_suffixes() if
               x[0] and x[2] not in ignore_types ]

def caller_path(path, level=2):
    if not os.path.isabs(path):
        module = caller_module(level+1)
        prefix = package_path(module)
        path = os.path.join(prefix, path)
    return path

def caller_module(level=2):
    module_globals = sys._getframe(level).f_globals
    module_name = module_globals['__name__']
    module = sys.modules[module_name]
    return module

def package_name(pkg_or_module):
    """ If this function is passed a module, return the dotted Python
    package name of the package in which the module lives.  If this
    function is passed a package, return the dotted Python package
    name of the package itself."""
    if pkg_or_module is None:
        return '__main__'
    pkg_filename = pkg_or_module.__file__
    pkg_name = pkg_or_module.__name__
    splitted = os.path.split(pkg_filename)
    if splitted[-1] in init_names:
        # it's a package
        return pkg_name
    return pkg_name.rsplit('.', 1)[0]

def package_of(pkg_or_module):
    """ Return the package of a module or return the package itself """
    pkg_name = package_name(pkg_or_module)
    __import__(pkg_name)
    return sys.modules[pkg_name]

def caller_package(level=2, caller_module=caller_module):
    # caller_module in arglist for tests
    module = caller_module(level+1)
    f = getattr(module, '__file__', '')
    if (('__init__.py' in f) or ('__init__$py' in f)): # empty at >>>
        # Module is a package
        return module
    # Go up one level to get package
    package_name = module.__name__.rsplit('.', 1)[0]
    return sys.modules[package_name]

def package_path(package):
    # computing the abspath is actually kinda expensive so we memoize
    # the result
    prefix = getattr(package, '__abspath__', None)
    if prefix is None:
        prefix = pkg_resources.resource_filename(package.__name__, '')
        # pkg_resources doesn't care whether we feed it a package
        # name or a module name within the package, the result
        # will be the same: a directory name to the package itself
        try:
            package.__abspath__ = prefix
        except:
            # this is only an optimization, ignore any error
            pass
    return prefix


```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user